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 call mount(el) from this page's script. The 3D world is optional: pass it a shared state object and it follows.
Accessibility
- Role and state. A real button with role="switch" and aria-checked (checked means night), as in Radix and shadcn.
- Keyboard. Tab to focus, Space or Enter toggles, Left and Right arrows set day or night. Focus ring uses the --ring token.
- Pointer. Click, or drag the knob to scrub time and release to snap. Touch-action keeps vertical scrolling working.
- Reduced motion. The sky jumps to the end state and the 3D loops stop; the world still renders a still frame.