Inputs & Switches
Rocker Switch
Photoreal I/O rocker in warm metal clunks between ON/OFF with spring physics and specular tilt. Amber LED witness light glows when on.
canvasheavy complexitymoderate motionclick
Open on the canvas to copy the code → Free account · 3 copies a day · membership goes unlimited
Worth keeping?
Votes steer what gets built next — sign in to cast one, free to read
When to use it
Hardware/industrial UI dashboards, retro control panel aesthetics, settings toggles where tactile feel is part of the brand.
When not to
Light or minimal UIs — background is hardcoded dark brown. Production forms needing strict user-controlled state — auto-cycles by default.
Working with an AI agent
Every component ships agent-ready metadata. An example instruction for this one:
Change the LED to blue by editing the lens gradient rgb formula: set `r=20+30*fil, g=50+80*fil, b=40+215*fil` and update glow halo stops to `rgba(90,150,255,...)`. Theme: dark tokens live in :root, the light variant in :root[data-theme="light"]; ?theme=light or a {type:'forever:theme'} postMessage switches at runtime.
Safe to edit
- LED glow color (rgba in gh gradient stops)
- spring stiffness and damping (k=0.20, damp=0.74)
- auto-flip interval (2600+random*900ms)
- plate proportions (pw=S*0.50, ph=S*0.66)
- specular highlight opacity (0.30*sp)
- theme tokens (:root dark defaults + [data-theme=light] overrides)
Keep intact
- DPR-aware canvas sizing and setTransform
- visibilitychange pause/start
- reduced-motion static fallback (reduce branch)
- IIFE wrapper
- theme hook (?theme= bootstrap + forever:theme message listener + theme tokens)
Known limitations
- pointermove hover bias alters target without a click — remove listener for strict click-only behavior
- Auto-cycles every ~2.6s — remove the nextFlip block before shipping in production
- Background color hardcoded in CSS (#1d1a16)
More Inputs & Switches components
- Liquid ToggleSVG toggle with a goo filter — the knob slides with trailing liquid droplets; track color fades between off and on states.
- Glow SliderSVG range slider with a plum-to-teal gradient fill, glowing knob, and a floating value bubble that tracks the handle; auto-oscillates when idle.
- Spring StepperMint-themed +/- stepper with a number reel that springs and overshoots between digits 0–9; auto-cycles as a demo. Dark green palette.
- Segmented ControlSlate-to-sage gradient pill slides between Day/Week/Month/Year segments with elastic spring stretch. Auto-cycles; click pauses briefly.
- Checkbox MorphThree amber rounded checkboxes auto-cycle and respond to clicks; the box fills and a checkmark strokes in via animated dashoffset.
- Star RatingFive gold stars auto-sweep ratings up and down; the active star pops with a scale bounce. Pointer sets the hover rating instantly.