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 radiogroup of role="radio" buttons with aria-checked, the Radix ToggleGroup (single) pattern. Only the checked button is a tab stop.
- Keyboard. Tab into the group, arrow keys move and select, Home and End jump to the ends. Space or Enter re-selects. Focus ring uses the --ring token.
- Reduced motion. With prefers-reduced-motion the magnetic pull is off and the puck jumps straight to the chosen button. The selection is still obvious from colour.
- Touch and contrast. Magnetism only runs for mouse and pen; touch taps select instantly. Targets are 44px tall. Colours come from tokens (AA in light, dark and every preset).