Counter Curtain

Page Preloader for React

A curtain that covers the page while it loads, counting from 0 to 100 with the fonts and hero images, then lifts as the headline rises out of its masks underneath, on one clock.

  • Preloader
  • Hero
  • Text

Uses clsx, tailwind-merge

Open in ChatGPTOpen in Claude
minDuration0.8s(replays the demo)
liftDuration0.90s(replays the demo)
riseDuration1.00s(replays the demo)
stagger0.08s(replays the demo)
direction(replays the demo)
<CounterCurtain />

replays the demo when you let go.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Counter Curtain: A curtain that covers the page while it loads, counting from 0 to 100 with the fonts and hero images, then lifts as the headline rises out of its masks underneath, on one clock.
This demo, Studio Portfolio: The default counter over a studio's home page. The nav, headline, links and photo each rise as the curtain clears them. Press reload in the address bar to play it again.

1. Install it:
   npx shadcn@latest add @keyframeui/counter-curtain-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/counter-curtain-demo.json instead.)
   It adds the demo, components/counter-curtain-demo.tsx, and the component, components/ui/counter-curtain.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <CounterCurtain> on its own.

3. These props set its feel. Change them before you change the file:
   - minDuration (default 0.8): Shortest the count can take, in seconds, even when everything has already loaded. Keep it under a second or so: it's a first impression, not a wait.
   - liftDuration (default 0.9): How long the curtain takes to slide off the page, in seconds. The lines start rising as its edge passes them, so they follow.
   - riseDuration (default 1): How long each line takes to rise out of its mask, in seconds.
   - stagger (default 0.08): Seconds between lines that sit together, like a headline's, as they rise in turn.
   - direction (default "up"): The way the curtain leaves. The lines always rise.

4. Don't change, in components/ui/counter-curtain.tsx:
   - `counterCurtain` is serialized with `toString()` into an inline script, so it stays self-contained: no outer variables, no imports, no async or object spread. It reads every value from the plan it's handed.
   - The count writes straight to the DOM and the lift and the rises are WAAPI transforms, so nothing re-renders and the reveal stays smooth while React hydrates underneath.
   - The count never lands before `minDuration`, never waits past `maxDuration` and creeps while it waits; its clock counts only visible time, and a click, key or scroll hurries it.
   - A line's rise starts as the curtain's edge passes it, solved from the lift's curve; lines that sit together rise in reading order, `stagger` apart.
   - Reduced motion, a session that already played it, or no `Element.animate` skips the curtain outright. `HIDDEN` must match the class on `CounterCurtainLine`'s inner span.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/counter-curtain.md

Installation

Add the component on its own with the CLI, or copy the file in by hand.

The CLI writes components/ui/counter-curtain.tsx and installs clsx and tailwind-merge. It needs the @keyframeui registry in components.json; add it once per project.

npx shadcn@latest add @keyframeui/counter-curtain

Examples

Finished sections built with Counter Curtain. Each one installs whole, with the component included.

Launch Page

A custom counter in the drop's colors, with a padded number and a progress bar, on a curtain that falls away. `onComplete` starts the countdown as it goes, so the clock is already ticking when it's uncovered.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Counter Curtain: A curtain that covers the page while it loads, counting from 0 to 100 with the fonts and hero images, then lifts as the headline rises out of its masks underneath, on one clock.
This demo, Launch Page: A custom counter in the drop's colors, with a padded number and a progress bar, on a curtain that falls away. `onComplete` starts the countdown as it goes, so the clock is already ticking when it's uncovered.

1. Install it:
   npx shadcn@latest add @keyframeui/counter-curtain-launch-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/counter-curtain-launch-demo.json instead.)
   It adds the demo, components/counter-curtain-launch-demo.tsx, and the component, components/ui/counter-curtain.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <CounterCurtain> on its own.

3. These props set its feel. Change them before you change the file:
   - minDuration (default 0.8): Shortest the count can take, in seconds, even when everything has already loaded. Keep it under a second or so: it's a first impression, not a wait.
   - liftDuration (default 0.9): How long the curtain takes to slide off the page, in seconds. The lines start rising as its edge passes them, so they follow.
   - riseDuration (default 1): How long each line takes to rise out of its mask, in seconds.
   - stagger (default 0.08): Seconds between lines that sit together, like a headline's, as they rise in turn.
   - direction (default "up"): The way the curtain leaves. The lines always rise.

4. Don't change, in components/ui/counter-curtain.tsx:
   - `counterCurtain` is serialized with `toString()` into an inline script, so it stays self-contained: no outer variables, no imports, no async or object spread. It reads every value from the plan it's handed.
   - The count writes straight to the DOM and the lift and the rises are WAAPI transforms, so nothing re-renders and the reveal stays smooth while React hydrates underneath.
   - The count never lands before `minDuration`, never waits past `maxDuration` and creeps while it waits; its clock counts only visible time, and a click, key or scroll hurries it.
   - A line's rise starts as the curtain's edge passes it, solved from the lift's curve; lines that sit together rise in reading order, `stagger` apart.
   - Reduced motion, a session that already played it, or no `Element.animate` skips the curtain outright. `HIDDEN` must match the class on `CounterCurtainLine`'s inner span.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/counter-curtain.md

Editorial

The default counter set in serif on a stone curtain that slides off to the left. It waits for the three photos to load and decode, so they're sharp from the first frame.

Take this demo to your coding agent.
Add this moment from KeyframeUI to our project and adapt it to our content.

Counter Curtain: A curtain that covers the page while it loads, counting from 0 to 100 with the fonts and hero images, then lifts as the headline rises out of its masks underneath, on one clock.
This demo, Editorial: The default counter set in serif on a stone curtain that slides off to the left. It waits for the three photos to load and decode, so they're sharp from the first frame.

1. Install it:
   npx shadcn@latest add @keyframeui/counter-curtain-editorial-demo
   (If the CLI can't find @keyframeui, use https://keyframeui.com/r/counter-curtain-editorial-demo.json instead.)
   It adds the demo, components/counter-curtain-editorial-demo.tsx, and the component, components/ui/counter-curtain.tsx.

2. Make it ours: our copy, data, images and colors. Keep the structure the motion depends on. If we only need the effect, use <CounterCurtain> on its own.

3. These props set its feel. Change them before you change the file:
   - minDuration (default 0.8): Shortest the count can take, in seconds, even when everything has already loaded. Keep it under a second or so: it's a first impression, not a wait.
   - liftDuration (default 0.9): How long the curtain takes to slide off the page, in seconds. The lines start rising as its edge passes them, so they follow.
   - riseDuration (default 1): How long each line takes to rise out of its mask, in seconds.
   - stagger (default 0.08): Seconds between lines that sit together, like a headline's, as they rise in turn.
   - direction (default "up"): The way the curtain leaves. The lines always rise.

4. Don't change, in components/ui/counter-curtain.tsx:
   - `counterCurtain` is serialized with `toString()` into an inline script, so it stays self-contained: no outer variables, no imports, no async or object spread. It reads every value from the plan it's handed.
   - The count writes straight to the DOM and the lift and the rises are WAAPI transforms, so nothing re-renders and the reveal stays smooth while React hydrates underneath.
   - The count never lands before `minDuration`, never waits past `maxDuration` and creeps while it waits; its clock counts only visible time, and a click, key or scroll hurries it.
   - A line's rise starts as the curtain's edge passes it, solved from the lift's curve; lines that sit together rise in reading order, `stagger` apart.
   - Reduced motion, a session that already played it, or no `Element.animate` skips the curtain outright. `HIDDEN` must match the class on `CounterCurtainLine`'s inner span.
   Its timing is all in the TIMING block at the top of that file.

Docs: https://keyframeui.com/components/counter-curtain.md

Props

children

TypeReact.ReactNode

The hero. Wrap each line of the headline, and anything else that should rise in, in CounterCurtainLine. Lines rise as the curtain's edge passes them, a beat apart, in reading order.

minDuration

TypenumberDefault0.8

Shortest the count can take, in seconds, even when everything has already loaded. Keep it under a second or so: it's a first impression, not a wait.

maxDuration

TypenumberDefault3

Longest it waits for loading, in seconds, before lifting anyway. While it waits, the count creeps on its own so it never looks stuck. A click, key press or scroll lands it within a third of a second.

liftDuration

TypenumberDefault0.9

How long the curtain takes to slide off the page, in seconds. The lines start rising as its edge passes them, so they follow.

riseDuration

TypenumberDefault1

How long each line takes to rise out of its mask, in seconds.

stagger

TypenumberDefault0.08

Seconds between lines that sit together, like a headline's, as they rise in turn.

waitFor

Type("fonts" | "images")[]Default["fonts", "images"]

What the count follows: web fonts, and the images in the visible part of the hero, decoded so the reveal doesn't stutter on them. [] makes it a plain timed count.

once

TypebooleanDefaulttrue

Play once per browser session. Reloads, the back button and other pages that use it go straight to the content.

storageKey

TypestringDefault"counter-curtain"

The sessionStorage key that remembers it played. Curtains with the same key share it.

direction

Type"up" | "down" | "left" | "right"Default"up"

The way the curtain leaves. The lines always rise.

counter

TypeReact.ReactNode

What the curtain shows in place of the default counter. Put <CounterCurtainValue pad={3} /> where the number goes, and use var(--counter-progress), from 0 to 1, for bars, like scale-x-[var(--counter-progress)].

onComplete

Type() => void

Called when the count reaches 100 and the curtain starts to lift, or straight away when it's skipped. Start a background video here, so it's already playing as it's uncovered.

contained

TypebooleanDefaultfalse

Cover this element instead of the screen, and leave the page's scroll alone. It starts counting once it's on screen. For a single section, or a preview like the ones here.

curtainClassName

Typestring

Classes for the curtain, such as its color and font.

className

Typestring

Classes for the element that wraps the hero. Other props pass through to it.

nonce

Typestring

Your Content Security Policy's nonce, for the small inline script that puts the curtain up before the page is drawn. If the script is blocked, the curtain is skipped.