Skip to content

Switch ​

A control that allows the user to toggle between checked and not checked.

Usage ​

Approximate web preview — the HarmonyOS rendering is the reference.

Sizes & cards ​

A settings list built from card switches.

Approximate web preview — the HarmonyOS rendering is the reference.

API ​

Extracted from the @Param / @Event / @BuilderParam declarations in the library sources.

SSwitch ​

shadcn-vue Switch: h-[1.15rem] w-8 rounded-full border border-transparent shadow-xs, unchecked bg-input dark:bg-input/80, checked bg-primary; the size-4 thumb slides translate-x-[calc(100%-2px)].

Variants: sizing sm | default | lg, description (muted text under the label) and card (label and description in a bordered, pressable card with the switch on the right; highlighted while on).

React to changes with onCheckedChange / !! (the control's own tap consumes .onClick() on SSwitch).

PropTypeDefaultDescription
checked!!boolean | undefinedundefinedControlled state (use with !!). Leave undefined for uncontrolled.
defaultCheckedbooleanfalse
disabledbooleanfalse
labelResourceStr | undefinedundefinedText shown to the right; also tappable.
descriptionResourceStr | undefinedundefinedMuted helper text under the label.
sizingChoiceSize
ChoiceSize = 'sm' | 'default' | 'lg'
'default'
cardbooleanfalseBordered choice card: texts on the left, switch on the right.
tokensSwitchTokens{}Per-instance token overrides (instance → theme --switch-* → recipe), see {@link SwitchTokens}.
EventTypeDefaultDescription
onCheckedChange(v: boolean) => void() => { }

MIT Licensed