Micro-interactions
Preloader
A percentage-counting load overlay. A spinning ring, an eased counter, and a fade-out that reveals the page beneath.
Install
bun add gsap clsx tailwind-mergeThen copy 2 files into your project:
- components/registry/preloader/preloader.tsx
- lib/utils.ts
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| duration | number | 3 | Simulated load time. |
| ringColor | string (hex) | "#a855f7" | Color of the spinner, counter, and label. |
| overlayColor | string (hex) | "#000000" | Overlay background color. |
| ringSize | number | 128 | Ring diameter. |
| spinSpeed | number | 1.5 | Seconds per spinner revolution. |
| holdDelay | number | 0.4 | Pause at 100% before the fade. |
| fadeDuration | number | 0.6 | Duration of the fade-out. |
| showLabel | boolean | true | Show the caption under the counter. |
What It Demonstrates
- Loop
- An animation that repeats, a set number of times or infinitely.
- Number ticker
- Digits rolling or counting up to a value.
- Fade in / Fade out
- Element appears or disappears by changing opacity.
- Easing
- The rate at which an animation speeds up or slows down.
- Perceived performance
- The right animation makes an interface feel faster, even when it isn't.
Related Components
Refract
A frosted-glass slab you drag across a live scene, refracting it through a real shader optic. A rounded-rect height field bends three separately-sampled color channels along its gradient, with a Fresnel-bright rim, a travelling specular streak, and a frost that is a genuine multi-tap blur of what sits beneath the pane. Where Lens bends its DOM children through an SVG displacement map and magnifies, Refract is a flat pane over a scene texture with true angle-of-incidence refraction, dispersion and glare, and the scene it bends is drawn in the same shader, because no browser lets WebGL read the rendered page. Throw it and it glides on momentum, rubber-banding off the container walls.
Intro Animation
A wind front sweeps the wordmark right to left. The instant it reaches a glyph the text hands off to a baseline-aligned field of GPU grain — same pixels, same colour, no seam — which peels crown-first and drifts away as smoke through a curl field. The backdrop opens behind it to reveal the page. Mount it over your app and unmount on onDone.
Live Activity
A live activity tracker in one black shape. A timer, a download, a delivery, a song and an AI agent take turns in it, and tapping it opens a full card. The text fades out before the shape moves and comes back after it stops, so it never stretches during the resize. The small pill and the big card share one clock and one state, so if you pause in the card, the pill is paused too. The agent is the main show. Three sparkles circle on a tilted orbit, the front one big and the back ones small, and they spin faster on every new step. The pill widens to show each new step's name, then shrinks back to the step count, and the card types out the command the agent is running.
Scratch
A scratch-off card. Drag over the foil to scrape it off, and small flakes fall where you scratch. Once enough foil is gone, the rest fades away on its own. A light glints across the foil now and then. You can also focus the card and press Enter or Space to reveal it.
Pixel Transition
Reveal a second layer through a random pixelated dissolve on hover.
Border Glow
A cursor-proximity gradient border with an outer glow.