forever components

Inputs & Switches

Segmented Control

Slate-to-sage gradient pill slides between Day/Week/Month/Year segments with elastic spring stretch. Auto-cycles; click pauses briefly.

cssmedium 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

Date-range pickers, tab bars, filter controls in dark-themed dashboards or app UIs.

When not to

Production use without removing the auto-cycle loop. Light-background UIs where the hardcoded dark background clashes.

Working with an AI agent

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

Change options to ['S','M','T','W'] in .opt divs, set pill gradient to linear-gradient(135deg,#f97316,#ec4899), slow spring by changing k from 0.18 to 0.10. 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

  • option labels (Day/Week/Month/Year in .opt divs)
  • pill gradient colors (#4B5560, #5A8C73)
  • spring stiffness (k=0.18) and damping (damp=0.65)
  • auto-cycle interval (auto>75)
  • pill stretch multiplier (vel*40)
  • theme tokens (:root dark defaults + [data-theme=light] overrides)

Keep intact

  • geometry cache (geoms array, measure() on resize only)
  • visibilitychange pause guard
  • IIFE wrapper
  • prefers-reduced-motion check
  • theme hook (?theme= bootstrap + forever:theme message listener + theme tokens)

Known limitations

  • Auto-cycles by default — remove before shipping in production
  • Light re-theme via the [data-theme=light] token block; catalog bg/accent describe the dark default
  • No aria-selected or role=tablist — add for full accessibility

segmented-controlpillspringui-controlgradientauto-cycletabs

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.
  • 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.
  • OTP BoxesFour teal monospace OTP cells auto-fill digits with a slide-up bounce and blinking caret; sequence clears and loops. Dark background with glow on active cell.