Toggle
Use Toggle for a button that keeps a pressed state, such as pinning or enabling a formatting option.
Preview
Pin states
Compare an icon-and-text toggle, an initially pressed toggle, and a disabled control.
Loading preview.
Installation
New to this Registry? Complete the base setup before continuing.
npx shadcn@latest add @neumorphism-ui/toggleInstall the shared base once, then add components and their dependencies with the CLI.
Usage
Give the control a clear label and set defaultPressed or controlled pressed state. Use ToggleGroup when several related pressed controls belong together.
"use client";
import { Toggle } from "@/components/ui/toggle";
export default function Example() {
return <Toggle aria-label="Bold">Bold</Toggle>;
}API Reference
A standalone button with a persistent pressed state. Label icon-only buttons. Selection also uses an inset surface and border, not color alone.
| Component | Prop | Type | Default | Description |
|---|---|---|---|---|
Toggle | pressed / defaultPressed | boolean | — | Set controlled or initial state. |
Toggle | size | "sm" | "default" | "lg" | — | Choose the control size. |
Toggle | disabled | boolean | — | Disable user interaction. |
Accessibility
- 01
Label icon-only buttons. Selection also uses an inset surface and border, not color alone.
- 02
Preserve labels and visible focus when customizing render or className.