docs/components/toggle-group
Sections
Components
Utilities
Forms
Hooks
Copy Markdown
Toggle buttons for selecting a value.
PreviewCode
CLIManual
pnpmbunnpmyarn
pnpm dlx shadcn@latest add @shark/toggle-group
ToggleGroup
└── ToggleGroupItem
import {
ToggleGroup,
ToggleGroupItem
} from "@/components/ui/toggle-group";
<ToggleGroup>
<ToggleGroupItem value="1">Item 1</ToggleGroupItem>
<ToggleGroupItem value="2">Item 2</ToggleGroupItem>
</ToggleGroup>
Use the value and onValueChange props to control the toggle group state programmatically.
PreviewCode
bold
Disable the entire group with the disabled prop.
PreviewCode
Disable individual toggles by setting disabled on a specific item.
PreviewCode
Use orientation to change the orientation of the toggle group.
PreviewCode
PreviewCode
Use variant to change the visual style of the toggle buttons.
PreviewCode
PreviewCode
Use spacing to add space between buttons.
PreviewCode
Use multiple={false} to allow only one toggle to be selected at a time.
PreviewCode
A custom toggle group example with a custom styling for font weight selection.
PreviewCode
Font Weight AaLightAaNormalAaMediumAaBold
Root component. Provides shared variant and size to child toggles via context.
| Prop | Type | Default |
|---|---|---|
variant | `"outline" | "ghost"` |
size | `"sm" | "md" |
spacing | `"0" | "1" |
multiple | boolean | true |
defaultValue | string[] | - |
value | string[] | - |
onValueChange | (details: ValueChangeDetails) => void | - |
orientation | `"horizontal" | "vertical"` |
disabled | boolean | false |
className | string | - |
| Attribute | Default |
|---|---|
--gap | Set from the spacing prop (default 0) |
Single toggle in the group. Uses Toggle internally.
| Prop | Type | Default |
|---|---|---|
value | string | required |
disabled | boolean | false |
className | string | - |
aria-label | string | - |
For a complete list of props, see the Ark UI documentation.
[
Previous page
Toast ](/docs/components/toast)[
Next page
Toggle Tooltip ](/docs/components/toggle-tooltip)
On This Page
InstallationAnatomyUsageControlledStatesDisabledWith disabled toggleOrientationHorizontalVerticalVariantGhostOutlineExamplesWith spacingSingle selectionCustom toggle groupAPI ReferenceToggleGroupToggleGroupItem