Skip to content

Toggle

A React source recipe with Base UI behavior and the public TIS Toggle classes and tokens.

Design

Functional preview

Running with the React source recipe distributed through shadcn and based on Base UI.

Loading functional preview…

Anatomy

1 2 3 4
1 Input (.ds-toggle) — styled <input type="checkbox"> with role="switch".
2 Track — CSS background that changes color based on checked state.
3 Thumb — CSS pseudo-element that slides left/right.
4 Content Frame (.ds-toggle__content) — wraps label, description and helper text.

Default

With description and helper text

Sizes

Disabled

States

StateCSS triggerVisual changeToken
Off---Neutral track with dark thumbcomponent.toggle.track.fill.off.default, component.toggle.thumb.fill.off.default
Off hover:hoverDarker neutral track/thumbcomponent.toggle.track.fill.off.hover, component.toggle.thumb.fill.off.hover
On:checkedPrimary track with light thumbcomponent.toggle.track.fill.on.default, component.toggle.thumb.fill.on.default
On hover:checked:hoverDarker primary trackcomponent.toggle.track.fill.on.hover, component.toggle.thumb.fill.on.hover
Focus:focus-visible2px outline ringcomponent.toggle.focus-ring.radius.default + component.focus-ring.*
Disabled[disabled]Muted track, thumb and labelcomponent.toggle.track.fill.*.disabled, semantic.content.disabled