∞ forever components

UI Micro-interactions

Battery Charge Fill

Battery cycles amber-to-mint as a wobbling liquid level rises; segment ticks light in sequence, bubbles rise inside, and a bolt pulses at center.

canvasmedium complexitymoderate motionpointermobile-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

Status indicators for charging progress, IoT dashboards, energy/health app hero widgets.

When not to

Contexts where a real battery percentage must be displayed — the charge is animated/simulated, not data-driven.

Working with an AI agent

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

Change palette to red/orange by updating AMBER=[239,68,68], LIME=[234,179,8], MINT=[251,191,36], and increase TICKS to 8. 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

  • color palette (AMBER, LIME, MINT arrays)
  • tick count (TICKS=6)
  • wave amplitude (1.6+charge*1.4)
  • phase speed (0.0042)
  • bubble count (i<5)
  • battery size (58*u wide, 92*u tall)
  • theme tokens (:root dark defaults + [data-theme=light] overrides)

Keep intact

  • IIFE wrapper
  • prefers-reduced-motion guard (reduce variable)
  • visibilitychange stop/start pattern
  • DPR-aware canvas sizing
  • 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

  • Charge is purely animated (sine cycle) — no API to bind a real percentage
  • Bubble positions are deterministic seed-based, not truly random
  • State remains local to each mounted instance; format/theme remount preserves takeover, not component values.

batteryliquid-fillcanvasui-widgetcolor-shiftambientmicrointeraction

More UI Micro-interactions components

  • Add to Cart FlyNative Add button flings a product clone into a cart; first input cancels unfinished attract flights, while each manual action keeps its full 680ms flight…
  • Notification BellSVG bell swings and rings with a ripple wave on click; a red badge counter pops in with a springy bounce and increments each ring. Auto-cycles every 2…
  • Copy ConfirmCopy icon morphs to a drawn-stroke checkmark with a green button flash and a "Copied!" toast on click; auto-cycles as a demo loop.
  • Swipe Card StackTinder-style draggable card stack — drag the top card left/right to reveal NOPE/LIKE stamps; fling-away animates it off-screen and cycles to the next card.
  • Pull to RefreshA phone-frame list supports pointer/touch pull and a native Refresh button. First input stops attract refreshes; manual refresh completes its spinner, row…
  • Accordion ExpandThree FAQ panels smoothly expand and collapse with a CSS height transition; a chevron rotates 180 degrees to indicate open state. Auto-cycles as demo.