Skip to content

Switch โ€‹

Source: client/lib/theme/vueda-tailwind/controls/index.js

The track of the sliding boolean control. Tighter than the iOS-canonical size: 18.4px tall (h-[1.15rem]), 32px wide (w-8), so the switch sits at the form density tier rather than ballooning above the 32px control row. Pill radius; checked fills --primary, unchecked fills --input (with a darker --input/80 tint in dark mode for visibility against the deeper canvas). Focus paints --ring directly on the otherwise-transparent 1px border and adds a 2px outline at 2px offset, rather than the canon focus-ring utility, because the track + thumb composition needs the ring to wrap the entire pill without the inset shadow variant interfering with the thumb's transform.

Vue component: Switch

SlotDefault classesDescription
root2 classesThe track of the sliding boolean control. Tighter than the iOS-canonical size: 18.4px tall (h-[1.15rem]), 32px wide (w-8), so the switch sits at the form density tier rather than ballooning above the 32px control row. Pill radius; checked fills --primary, unchecked fills --input (with a darker --input/80 tint in dark mode for visibility against the deeper canvas). Focus paints --ring directly on the otherwise-transparent 1px border and adds a 2px outline at 2px offset, rather than the canon focus-ring utility, because the track + thumb composition needs the ring to wrap the entire pill without the inset shadow variant interfering with the thumb's transform.
thumb2 classesThe sliding indicator inside Switch.root. 16px circle (size-4) sized to fit inside the 18.4px track with a 1.2px gap on each axis; translate-x-[calc(100%-2px)] shifts the thumb the track width on checked state and parks it 2px in from the trailing edge so a hairline of track stays visible. Fill flips by palette: bg-background on light, bg-foreground (unchecked) or bg-primary-foreground (checked) on dark, so the thumb reads opposite the track tone in both palettes. transition-transform because only the position animates; the fill flip is instant to stay aligned with the track's state change.

root โ€‹

The track of the sliding boolean control. Tighter than the iOS-canonical size: 18.4px tall (h-[1.15rem]), 32px wide (w-8), so the switch sits at the form density tier rather than ballooning above the 32px control row. Pill radius; checked fills --primary, unchecked fills --input (with a darker --input/80 tint in dark mode for visibility against the deeper canvas). Focus paints --ring directly on the otherwise-transparent 1px border and adds a 2px outline at 2px offset, rather than the canon focus-ring utility, because the track + thumb composition needs the ring to wrap the entire pill without the inset shadow variant interfering with the thumb's transform.

Default classes:

text
peer data-[state=checked]:bg-primary data-[state=unchecked]:bg-input focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring dark:data-[state=unchecked]:bg-input/80
inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-vueda-control transition-all disabled:cursor-not-allowed disabled:opacity-50

Source: client/lib/theme/vueda-tailwind/controls/Switch.theme.js:17

thumb โ€‹

The sliding indicator inside Switch.root. 16px circle (size-4) sized to fit inside the 18.4px track with a 1.2px gap on each axis; translate-x-[calc(100%-2px)] shifts the thumb the track width on checked state and parks it 2px in from the trailing edge so a hairline of track stays visible. Fill flips by palette: bg-background on light, bg-foreground (unchecked) or bg-primary-foreground (checked) on dark, so the thumb reads opposite the track tone in both palettes. transition-transform because only the position animates; the fill flip is instant to stay aligned with the track's state change.

Default classes:

text
bg-background dark:data-[state=unchecked]:bg-foreground dark:data-[state=checked]:bg-primary-foreground
pointer-events-none block size-4 rounded-full ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0

Source: client/lib/theme/vueda-tailwind/controls/Switch.theme.js:27

Documents matching: server v3.0.0a1.post1client v3.0.0-alpha.2