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. The control is a native button with role="switch" and aria-checked (off = monthly, on = yearly) and an accessible name. The status line is a polite live region that announces "Flipping the coin" and the new billing summary. The disabled variant uses the native disabled attribute.
- Keyboard. Tab to the switch, Space or Enter flips it. Clicking the 3D coin is a pointer extra; the switch alone reaches every state. While the coin is in the air further toggles are ignored so the visible price never disagrees with the state. Focus ring uses the --ring token.
- Reduced motion. With prefers-reduced-motion the coin simply turns to the new face and the price updates in place: no toss, no coin shower, no camera shake, no god-ray movement.
- Contrast. The card uses the colour tokens (AA in light, dark and every preset); the coin is a decorative aria-hidden canvas and the same price is always printed as real text in the card.