Toggle & Group
A two-state button that can be either on or off.
Usage
Approximate web preview — the HarmonyOS rendering is the reference.
Controlled
Bind pressed with !! like v-model:pressed.
Approximate web preview — the HarmonyOS rendering is the reference.
Toggle Group
A set of two-state buttons joined into one control. value is a string array for both single and multiple groups.
Approximate web preview — the HarmonyOS rendering is the reference.
Toggle Group — controlled
Approximate web preview — the HarmonyOS rendering is the reference.
API
Extracted from the @Param / @Event / @BuilderParam declarations in the library sources.
SToggle
shadcn-vue Toggle: a two-state button that can be either on or off.
The toggle handles taps itself; observe changes with onPressedChange (or !!). A native .onClick() on SToggle does not fire because the inner tap wins.
| Prop | Type | Default | Description |
|---|---|---|---|
pressed!! | boolean | undefined | undefined | Controlled state (use with !!). Leave undefined for uncontrolled. |
defaultPressed | boolean | false | |
variant | ToggleVariantToggleVariant = 'default' | 'outline' | 'default' | |
sizing | ToggleSizeToggleSize = 'default' | 'sm' | 'lg' | 'default' | |
text | ResourceStr | undefined | undefined | |
icon | string | undefined | undefined | Leading lucide icon name. |
label | string | undefined | undefined | Accessible name; required for icon-only toggles. |
disabled | boolean | false | |
tokens | ToggleTokens | {} | Per-instance token overrides (instance → theme --toggle-* → recipe), see {@link ToggleTokens}. |
| Event | Type | Default | Description |
|---|---|---|---|
onPressedChange | (pressed: boolean) => void | () => { } |
Slots: children (trailing closure)
SToggleGroup
shadcn-vue ToggleGroup: a set of two-state buttons joined into one control.
value is always a string array (for type: 'single' it holds at most one entry; tapping the selected item again clears it, like Radix). In single mode the selection is one indicator that slides between items (motion key toggle-group), so a selection change never flashes or cross-fades two items.
| Prop | Type | Default | Description |
|---|---|---|---|
type | ToggleGroupTypeToggleGroupType = 'single' | 'multiple' | 'single' | |
value!! | string[] | undefined | undefined | Controlled pressed items (use with !!). Leave undefined for uncontrolled. |
defaultValue | string[] | [] | |
variant | ToggleVariantToggleVariant = 'default' | 'outline' | 'default' | |
sizing | ToggleSizeToggleSize = 'default' | 'sm' | 'lg' | 'default' | |
disabled | boolean | false | |
spacing | number | 0 | Gap between items in vp (shadcn spacing). 0 = joined segments. |
wrap | boolean | false | Wrap items onto several lines when they do not fit (use with spacing). |
deselectable | boolean | true | single only: tapping the selected item again clears the selection (Radix default: true). |
| Event | Type | Default | Description |
|---|---|---|---|
onValueChange | (value: string[]) => void | () => { } |
Slots: children (trailing closure)
SToggleGroupItem
One item of a toggle group; inherits variant / sizing from the group.
| Prop | Type | Default | Description |
|---|---|---|---|
value | string | '' | |
text | ResourceStr | undefined | undefined | |
icon | string | undefined | undefined | Leading lucide icon name. |
label | string | undefined | undefined | Accessible name; required for icon-only items. |
disabled | boolean | false |
Slots: children (trailing closure)