Micro-interactions
Preloader
A percentage-counting load overlay — spinning ring, 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 whose gradient bends three separately-sampled color channels, 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: 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.
Pixel Transition
Reveal a second layer through a random pixelated dissolve on hover.
Border Glow
A cursor-proximity gradient border with an outer glow.
Spotlight Shell
A card shell with 3D magnetic tilt, radial glow, and a shimmer sweep.
Animated Hamburger
A three-bar hamburger that morphs to an X, driven by a toggle prop.
Morph Dialog
A dialog that morphs open from its trigger via shared-layout animation, with elements that travel between card and panel.