forever components

Buttons & Toggles

Async Action Button

A copy button that runs its own three states: idle, working (a short accent arc spins in the icon slot while the label reads 'copying') and done (the button fills accent and a tick draws itself). A mono line under it reports the component id and size.

csslight 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

Copy, save, submit or fetch actions where the button itself should confirm the work landed — clipboard copies, form saves, one-shot API calls.

When not to

Actions that take longer than a couple of seconds (use a progress line) or need cancel; toolbars with many simultaneous async buttons.

Working with an AI agent

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

Edit the labels in set() ('copy component' / 'copying' / 'copied'), the items array that the mono line cycles, and the phase lengths WORK=1400, DONE=1700, GAP=1900; change the icon by replacing the .ab13-plus path. 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

  • labels in set() and the items array (id + size pairs)
  • phase lengths (WORK, DONE, GAP in ms)
  • icon paths (.ab13-plus, .ab13-tick) and spinner arc length (stroke-dasharray 15.8 56.6)
  • accent + on-accent tokens (--ab13-accent, --ab13-on-accent)
  • theme tokens (:root dark defaults + [data-theme=light] overrides)

Keep intact

  • IIFE wrapper
  • state machine in set()/tick() — a real click and the idle demo run the same trigger()
  • prefers-reduced-motion guard (no demo clock, click resolves without the spin)
  • visibilitychange pause
  • pathLength=1 on the tick path (the draw is a 1→0 dashoffset)
  • theme hook (?theme= bootstrap + forever:theme message listener + theme tokens)

Known limitations

  • The idle demo triggers itself every ~2 s — set demo=false (or remove the clock) in a product
  • The done state auto-returns to idle after DONE ms; there is no error state

buttonasyncloadingspinnercheckstateclipboardcopymono

More Buttons & Toggles components

  • Magnetic ButtonDark pill button drifts in an idle orbital float; cursor proximity pulls it magnetically with a label inner-parallax and emerald-to-copper glow on hover.
  • Gooey Liquid TogglePill toggle where an SVG goo-filtered blob stretches and merges as it slides from off to on, shifting grey to magenta. Auto-cycles as demo.
  • Morphing Action FABGradient FAB whose plus icon rotates 135° to an X on click, fanning six icon buttons outward in a staggered radial spring animation. Auto-cycles in demo mode.
  • Material RippleDark rounded button that spawns an expanding ink ripple from the tap point; idles by firing ripples from random positions every 1.5 s.
  • Neon Glow PulseAmber pill button on near-black that breathes a bright neon bloom via opacity pulse on a pseudo-element; hover shifts background and text color.
  • Jelly PressAurora-gradient button squashes and stretches with a spring keyframe animation on click; auto-cycles idle squish every 2.1s to stay alive at rest.