Variants
Sizes and states, all built from the same markup.
Usage
Paste the markup, include assets/css/tokens.css and assets/css/tailwind.css, then run the script from this page.
Accessibility
- Role and state. A real button with role="switch" and aria-checked, as in Radix and shadcn.
- Keyboard. Tab to focus, Space or Enter to toggle. Focus ring uses the --ring token.
- Reduced motion. With prefers-reduced-motion the animation jumps to its end state; the state change is still clear.
- Contrast. Colours come from the tokens, which keep AA contrast in light and dark and in every preset.