Toggle group: Controlled
Pass value and onValueChange. Ignoring the empty value keeps one item on, so pressing the picked item again does nothing.
Showing the Board view.
This adds the example as components/examples/toggle-group/controlled.tsx, together with the Toggle group component and the HextaUI theme tokens it needs.
pnpm dlx shadcn@latest add https://hextaui.com/r/toggle-group-controlled.jsonTo add only the component, follow the Toggle group installation.
Props in this example
The Toggle group props this example sets, from the API reference.
| Prop | Type | Default |
|---|---|---|
value | string[] | – |
onValueChange | (value: string[], details) => void | – |
variantSets every item's variant. | "default" | "outline" | "default" |
| Prop | Type | Default |
|---|---|---|
valueIdentifies the item in the group's value. | string | – |
Every prop is in the Toggle group API reference.
See them all, with keyboard support and accessibility notes, on the Toggle group page.
- MotionThe easing curves, durations and reduced-motion check every component animates with, plus hooks for size morphs and sliding highlights.
- ToggleA button that stays on or off, with a fill that settles in when pressed, a clear hover-to-on step and icons that can fill with the state.
- ButtonButtons in every variant and size, with a built-in loading, success and error flow that skips the spinner for fast requests.
- Button groupButtons joined into one control, with shared seams, separators, text addons, nesting and vertical stacks.