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

Then copy 2 files into your project:

  • components/registry/preloader/preloader.tsx
  • lib/utils.ts

Props

PropTypeDefaultDescription
durationnumber3Simulated load time.
ringColorstring (hex)"#a855f7"Color of the spinner, counter, and label.
overlayColorstring (hex)"#000000"Overlay background color.
ringSizenumber128Ring diameter.
spinSpeednumber1.5Seconds per spinner revolution.
holdDelaynumber0.4Pause at 100% before the fade.
fadeDurationnumber0.6Duration of the fade-out.
showLabelbooleantrueShow 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

Appears In