bit Bheadless

Switch

An accessible on/off toggle styled entirely with Tailwind utilities.

Implementation: CSS Tailwind

Basic Switch (Uncontrolled)

Renders a native <button> with role="switch". The track and thumb are styled with the custom data-state-checked: variant.

Controlled

Drive the state externally with Checked + OnCheckedChange.

Notifications: on

Disabled

data-disabled: dims the track and disables interaction.

With label

Wrap in a <label> to make the text clickable.

As a non-native element

As="div" renders a div while keeping ARIA, tabindex, and keyboard handling intact.

Form Submission

Set Name to render an adjacent hidden input.

An unhandled error has occurred. Reload ๐Ÿ—™