docs/components/toggle
Sections
Components
Utilities
Forms
Hooks
Copy Markdown
Two-state button that can be toggled on or off.
PreviewCode
Toggle
CLIManual
pnpmbunnpmyarn
pnpm dlx shadcn@latest add @shark/toggle
import {
Toggle,
ToggleIndicator
} from "@/components/ui/toggle";
<Toggle>
<ToggleIndicator />
</Toggle>
Use the pressed and onPressedChange props to control the toggle state programmatically.
PreviewCode
Toggle
❌
Use the disabled prop to disable the toggle.
PreviewCode
Disabled
PreviewCode
Toggle
PreviewCode
Toggle
PreviewCode
Small
PreviewCode
Medium
PreviewCode
Large
Use multiple toggles with icons for toolbar-style controls.
PreviewCode
Toggle button for on/off or selected state. Use asChild for custom elements.
| Prop | Type | Default |
|---|---|---|
variant | `"outline" | "ghost"` |
size | `"sm" | "md" |
pressed | boolean | - |
defaultPressed | boolean | false |
disabled | boolean | false |
onPressedChange | (details: PressedChangeDetails) => void | - |
className | string | - |
asChild | boolean | false |
Icon or indicator shown when toggle is active. Omitted when used as child.
| Prop | Type | Default |
|---|---|---|
className | string | - |
asChild | boolean | false |
For a complete list of props, see the Ark UI documentation.
[
Previous page
Toggle Tooltip ](/docs/components/toggle-tooltip)[
Next page
Tooltip ](/docs/components/tooltip)
On This Page
InstallationUsageControlledStatesDisabledVariantsDefaultOutlineSizesSmallMediumLargeExamplesIcon GroupAPI ReferenceToggleToggleIndicator