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 motionpointer
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
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)
Known limitations
- Charge is purely animated (sine cycle) — no API to bind a real percentage
- Bubble positions are deterministic seed-based, not truly random
More UI Micro-interactions components
- Add to Cart FlyProduct tile flings a mini clone in a bezier arc into a cart icon on click; badge count bumps with a spring bounce. Auto-cycles as demo.
- 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 mockup with draggable list rows; pulling down reveals a teal arc spinner that fills and rotates, then triggers a skeleton-row flash on release.
- 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.