forever components

Inputs & Switches

Detent Knob

Knurled rotary knob snaps through 12 detents via a Hooke's-law spring; tick marks flash orange on land and a two-digit value readout counts up.

canvasmedium complexitymoderate motionclick

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 →
Worth keeping? Votes steer what gets built next — sign in to cast one, free to read

When to use it

Audio/synth UIs, settings panels, or any control demo needing a tactile rotary feel with discrete stepped values.

When not to

Contexts needing continuous value input or pointer-drag rotation rather than click-nudge stepping.

Working with an AI agent

Every component ships agent-ready metadata. An example instruction for this one:

Change STEPS to 8 for coarser detents, set ACC to '#00eaff' for a cyan accent, and increase K to 0.035 for a snappier spring. 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

  • detent count (STEPS=12)
  • accent color (ACC='#ff5c3a')
  • spring stiffness (K=0.020)
  • damping factor (DAMP=0.86)
  • knob size ratio (R=min(W,H)*0.30)
  • auto-advance dwell range (38+random*34)
  • idle demo cadence (LEAD=18 / GAP=12 / BACK=108 / CYCLE=180 / RESUME=216 frames, SWEEP=3 detents)
  • theme tokens (:root dark defaults + [data-theme=light] overrides)

Keep intact

  • DPR-aware canvas sizing
  • visibilitychange stop/start guards
  • prefers-reduced-motion snap fallback
  • idle demo sweep (same detent path as a real drag; real input takes over, resumes after RESUME)
  • theme hook (?theme= bootstrap + forever:theme message listener + theme tokens)

Known limitations

  • Click nudges one detent at a time — no drag-to-rotate gesture
  • Auto-cycles by default; remove autopilot block for production
  • Value readout is index 0-11, not a mapped real-world range

knobrotarydetentspringcanvasui-controlreadout

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.