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 button with role="switch" and aria-checked, as in Radix and shadcn. The visible text (Wall power, Unplugged or Powered) names and describes it, and a polite live region announces the change. The 3D scene is aria-hidden decoration.
- Keyboard. Tab to focus, Space or Enter toggles. The focus ring uses the --ring token; the keyboard plugs in the same 3D plug as the mouse.
- Reduced motion. With prefers-reduced-motion the plug jumps to its end position: no swing, sparks, flash or flicker, but the state change, label and lamp remain obvious.
- Contrast. Colours come from the tokens, which keep AA contrast in light and dark and in every preset.