Skip to content

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.

PropTypeDefaultDescription
pressed!!boolean | undefinedundefinedControlled state (use with !!). Leave undefined for uncontrolled.
defaultPressedbooleanfalse
variantToggleVariant
ToggleVariant = 'default' | 'outline'
'default'
sizingToggleSize
ToggleSize = 'default' | 'sm' | 'lg'
'default'
textResourceStr | undefinedundefined
iconstring | undefinedundefinedLeading lucide icon name.
labelstring | undefinedundefinedAccessible name; required for icon-only toggles.
disabledbooleanfalse
tokensToggleTokens{}Per-instance token overrides (instance → theme --toggle-* → recipe), see {@link ToggleTokens}.
EventTypeDefaultDescription
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.

PropTypeDefaultDescription
typeToggleGroupType
ToggleGroupType = 'single' | 'multiple'
'single'
value!!string[] | undefinedundefinedControlled pressed items (use with !!). Leave undefined for uncontrolled.
defaultValuestring[][]
variantToggleVariant
ToggleVariant = 'default' | 'outline'
'default'
sizingToggleSize
ToggleSize = 'default' | 'sm' | 'lg'
'default'
disabledbooleanfalse
spacingnumber0Gap between items in vp (shadcn spacing). 0 = joined segments.
wrapbooleanfalseWrap items onto several lines when they do not fit (use with spacing).
deselectablebooleantruesingle only: tapping the selected item again clears the selection (Radix default: true).
EventTypeDefaultDescription
onValueChange(value: string[]) => void() => { }

Slots: children (trailing closure)

SToggleGroupItem ​

One item of a toggle group; inherits variant / sizing from the group.

PropTypeDefaultDescription
valuestring''
textResourceStr | undefinedundefined
iconstring | undefinedundefinedLeading lucide icon name.
labelstring | undefinedundefinedAccessible name; required for icon-only items.
disabledbooleanfalse

Slots: children (trailing closure)

MIT Licensed