forever components

UI Micro-interactions

Swipe Card Stack

Tinder-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.

cssmedium complexitymoderate motionpointer

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

Onboarding flows, product showcases, or any swipe-to-decide UI pattern on mobile or desktop.

When not to

Contexts requiring all cards to be visible simultaneously, or where auto-cycling motion would distract (remove the loop timer before shipping).

Working with an AI agent

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

Change the card data array to use brand colors and icons, e.g. replace data with [['#C08459','🚀'],['#ec4899','💎'],['#f59e0b','⚡']] and increase fling distance from 400 to 600. 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

  • card data (color + emoji pairs in data array)
  • fling threshold (Math.abs(dx)>50)
  • fling distance (dir*400)
  • stamp colors (.like color/#2BAB6B, .nope color/#ff5c7a)
  • idle demo cadence (FIRST=600 / DEMO_EVERY=2500 / IDLE_BACK=3600 ms)
  • theme tokens (:root dark defaults + [data-theme=light] overrides)

Keep intact

  • visibilitychange stop/loop guard
  • touch event listeners for mobile support
  • drag=null null-guard before fling
  • drag guard in tick() — the demo never fires while a card is held
  • theme hook (?theme= bootstrap + forever:theme message listener + theme tokens)

Known limitations

  • shade() function is a no-op stub — gradient end color equals start color
  • Idle demo cycle runs by default (real input takes over, resumes after a few idle seconds) — remove the demo block for purely on-demand interaction
  • Card pool is only 5 items; idx wraps modulo data.length so short lists repeat quickly

swipecard-stackdraggesturetindermicrointeractiontouch

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.
  • 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.
  • Tooltip PopHeart icon button springs a mint-green tooltip above it on hover with a cubic-bezier spring pop; click triggers a subtle press-bounce via Web Animations API.