Switch

@sushindustries/ui

A checkbox that admits it: a real input with role=switch, and a track :checked drives.

4 min read
View as MarkdownEdit on GitHub

Switch is a checkbox that admits what it is: a real input carrying role="switch", drawn as a track and thumb on its label. Reach for it for a setting that takes effect the instant it is toggled, not one that waits for a form to be submitted.

Viewport width
Phone22remthe floor, the narrowest this promises to work at
tanstacktanstack add https://adamjurek.com/r/tanstack/switch.jsonshadcnpnpm dlx shadcn@latest add https://adamjurek.com/r/shadcn/switch.json

Why it is built this way

role="switch" without a managed aria-checked is a promise half kept, so the input underneath stays a genuine, native checkbox rather than a styled div faking the semantics - announced honestly, with the track and thumb driven by :checked rather than by React state.

Install

tanstack add https://adamjurek.com/r/tanstack/switch.json
shell
pnpm dlx shadcn@latest add https://adamjurek.com/r/shadcn/switch.json
shell
pnpm add @sushindustries/ui @sushindustries/atoms
shell

What you get

Version0.1.0
Categorycontent · Forms
Filesswitch.tsx
DependenciesNone
Tagsform, toggle, no-deps

No runtime dependencies

It brings nothing with it beyond the stylesheet.