∞ 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 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

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)
  • autonomous preview until first deliberate input cadence (FIRST=600 / DEMO_EVERY=2500 ms)
  • theme tokens (:root dark defaults + [data-theme=light] overrides)

Keep intact

  • visibilitychange stop/loop guard
  • single pointer ownership and cancellation rollback; vertical pan and pinch zoom remain available
  • 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)
  • 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

  • shade() function is a no-op stub — gradient end color equals start color
  • Autonomous demo stops at first input; drag, Skip/Keep buttons and left/right arrows remain available. Explicit preview restart restores the demo.
  • Card pool is only 5 items; idx wraps modulo data.length so short lists repeat quickly
  • State remains local to each mounted instance; format/theme remount preserves takeover, not component values.

swipecard-stackdraggesturetindermicrointeractiontouch

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