UI Micro-interactions
Accordion Expand
Three FAQ panels smoothly expand and collapse with a CSS height transition; a chevron rotates 180 degrees to indicate open state. Auto-cycles as demo.
csslight complexitysubtle motionclick
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
FAQ sections, product detail pages, settings panels — any context needing collapsible content with clear open/closed affordance.
When not to
Remove auto-cycle timer before shipping in production. Not suitable when all answers must be visible simultaneously.
Working with an AI agent
Every component ships agent-ready metadata. An example instruction for this one:
Change the accent color from #DA3E8C to #C0B459, add a fourth FAQ item with question 'Privacy' and answer 'We never sell your data.', and increase the step interval to 3000ms. 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
- FAQ data array (data)
- chevron accent color (#DA3E8C)
- auto-cycle interval (2200ms)
- panel background (#211c33)
- transition duration (.34s cubic-bezier)
- theme tokens (:root dark defaults + [data-theme=light] overrides)
Keep intact
- height-to-auto trick via transitionend listener
- IIFE-equivalent const scoping
- prefers-reduced-motion guard on loop()
- visibilitychange pause
- theme hook (?theme= bootstrap + forever:theme message listener + theme tokens)
Known limitations
- Auto-cycles by default — remove setInterval loop before production use
- No aria-expanded on trigger elements — add for full accessibility
- Panel width capped at 230px max-width; may feel narrow on desktop
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.
- 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.