∞ forever components

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 motionclickmobile-ready

Open on the canvas to copy the code → Free account · 3 copies a day · membership goes unlimited

Live demo — the real component, running in a sandbox. One self-contained HTML file, zero dependencies. Open it on the canvas →
1

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)
  • demo-v1 preview lifecycle: initialize demoEnabled from window.__foreverPreview and stop attract work on the window forever:interactive event; retain manual feedback, settling, cleanup and explicit sessions

Known limitations

  • Background color hardcoded in CSS (#1d1a16)
  • Pointer click and Space/Enter toggle the rocker; hover leaves the selected state intact.
  • State remains local to each mounted instance; format/theme remount preserves takeover, not component values.

rocker-switchcanvasui-controlphotorealspring-physicsledtoggle

More Inputs & Switches components

  • Liquid ToggleSVG liquid toggle with a goo filter, trailing droplets and a native button. First deliberate input stops the idle demo; the chosen on/off state settles fully.
  • Glow SliderSVG range slider with a muted plum-to-teal fill, glow and value bubble, driven by a native range input. First input stops demo oscillation; drag and…
  • Spring StepperMint stepper with native minus/plus buttons and a number reel that settles with spring feedback. First deliberate input stops automatic steps; the chosen…
  • Segmented ControlSlate-to-sage pill slides between four native segment buttons with elastic spring stretch. First input stops automatic cycling; committed selection remains.
  • Checkbox MorphThree native amber checkbox buttons animate their check strokes and expose pressed state. First input stops the demo; checked values remain.
  • Star RatingFive gold SVG star radio controls commit ratings on click or keyboard input and settle with a scale bounce. First input stops automatic sweeping.