shadcn.io is an independent project built on shadcn/ui
The switch starts off. The word on the leading side reads Off, and the other side reads On. Turning it on swaps those words. Its accessible name is Power.
Use swapping words when the state must be spelled out and stay in agreement with the switch. A fixed On label will lie once the switch is off. A form field can be a Checkbox. In Vue, Ark UI reports each change, and this demo stores it so the words match.
Installation
Anatomy

Usage
<div class="flex items-center gap-2">
<span class="font-medium text-sm">{{ checked ? "On" : "Off" }}</span>
<Switch aria-label="Power" :checked="checked" @checked-change="handleCheckedChange" />
<span class="text-muted-foreground text-sm">{{ checked ? "Off" : "On" }}</span>
</div>FAQ
Which side says On?
The first span shows On when the switch is on and Off when it is off, with font-medium text-sm. The second span shows the other word with text-muted-foreground text-sm. The row is flex items-center gap-2.
How do I control this switch in Vue?
This file keeps the state itself, starting off, and passes it back to the Switch. Both words read that same state.
Bind it with v-model:checked, or listen to @checked-change, which receives details.checked.
What do screen readers call this switch?
It has no visible label, so the demo passes aria-label (Power). Change it to the setting the switch controls, or use a visible FieldLabel instead.
How do I add a visible label to this switch?
Put the Switch in a horizontal Field next to a FieldLabel. Clicking the label toggles the switch, and screen readers read the label with it.
The Field links the label to the switch for you.
API Reference
Switch
Sets aria-label="Power", checked="checked" and checked-change="handleCheckedChange". The rest is on the Switch page.




