A countdown to a moment, in days, hours, minutes and seconds. Only the digit that changes moves, so it reads as a steady figure that ticks. Roll it, or flip it like a split-flap board.
On this page
- Launch day timer
- Waitlist closes
- Sale ends
- Event starts
- Beta window
Examples
A minute rollover
When the seconds pass 00 the minute moves with them.
Sizes and units
Installation
npx knowns-ui@latest add countdownPaste this into your coding agent (Claude Code, Cursor, Codex). It checks your project, sets up the registry, runs the install and verifies it.
Install Countdown from Knowns UI into this project. Work step by step, show me each change, and ask before you edit files outside this project.
Context: Knowns UI (https://ui.knowns.dev) is a shadcn registry. Items land in the project as source files. Docs: https://ui.knowns.dev/docs/countdown
1. Check the project first. Stop and tell me if any of these is missing:
- React 19 and Tailwind CSS v4.
- A components.json at the project root. If there is none, ask me before running `npx knowns-ui@latest init --no-key` (it runs shadcn init when needed, then adds the registries).
2. Run:
```bash
npx knowns-ui@latest add countdown
```
It writes these files:
- lib/knowns/run.ts
- lib/knowns/json.tsx
- lib/knowns/status.ts
- lib/knowns/tone.ts
- lib/knowns/types.ts
- lib/knowns/use-abortable.ts
- lib/knowns/utils.ts
- lib/knowns/motion.tsx
- lib/knowns/motion-utils.ts
- components/ui/knowns/countdown/countdown.tsx
- components/ui/knowns/countdown/countdown-utils.ts
and installs these npm packages: clsx@^2.1.1, tailwind-merge@^3.7.0.
3. While it runs:
- It also adds a few @keyframes (all named kn-*) to the global CSS file (globals.css or the file components.json points at). Let it: they only add animations.
- If it asks to overwrite files under lib/knowns/: these are shared by every Knowns UI item. List them, say whether I changed them (check git), and ask me before you answer.
- If it asks to overwrite any other file, show me the diff and ask me.
4. Verify:
- Every file in the list above exists.
- The project type-checks (for example `npx tsc --noEmit`) and the dev build has no new errors.
5. Use it: follow the examples and props on https://ui.knowns.dev/docs/countdown, and ask me if anything about my data is unclear.
If the Knowns UI MCP server is connected (https://ui.knowns.dev/docs/ai-and-mcp), use get_component({ name: "countdown" }) or search_docs for details.
Finish with a short summary: the files you added or changed, the packages you installed, and anything I still need to do.Props
- torequired
Date|number- The moment it counts to, or ms since the epoch.
- units
("days" | "hours" | "minutes" | "seconds")[]- Default
all four - Which units to show. The largest one takes everything above it: without days, three days left is 72 hours.
- variant
"roll"|"flip"- Default
"roll" - roll: the old digit leaves downward and the new one comes in from above. flip: a split-flap, the top half folds down and the new bottom half falls into place.
- size
"sm"|"md"|"lg"|"display"- Default
"md" - The digit size. lg and display shrink with a narrow window; display is for a hero.
- labels
boolean|Partial<Record<unit, string>>- Default
true - A caption under each unit: Days, Hours, Minutes, Seconds, your own words, or none.
- separators
boolean- Default
false - A colon between the units.
- onDone
() => void- Called once when the time runs out, or on mount when the moment has already passed.
- now
number- A fixed clock in ms, for tests and screenshots. Without it the countdown follows the visitor's clock.
- placeholder
string- Default
"--" - Shown until the browser's clock is read, so the server and the browser agree.
- className
string- Classes for the outer element.
| Prop | Type | Default | Description |
|---|---|---|---|
| torequired | Date | number | required | The moment it counts to, or ms since the epoch. |
| units | ("days" | "hours" | "minutes" | "seconds")[] | all four | Which units to show. The largest one takes everything above it: without days, three days left is 72 hours. |
| variant | "roll" | "flip" | "roll" | roll: the old digit leaves downward and the new one comes in from above. flip: a split-flap, the top half folds down and the new bottom half falls into place. |
| size | "sm" | "md" | "lg" | "display" | "md" | The digit size. lg and display shrink with a narrow window; display is for a hero. |
| labels | boolean | Partial<Record<unit, string>> | true | A caption under each unit: Days, Hours, Minutes, Seconds, your own words, or none. |
| separators | boolean | false | A colon between the units. |
| onDone | () => void | - | Called once when the time runs out, or on mount when the moment has already passed. |
| now | number | - | A fixed clock in ms, for tests and screenshots. Without it the countdown follows the visitor's clock. |
| placeholder | string | "--" | Shown until the browser's clock is read, so the server and the browser agree. |
| className | string | - | Classes for the outer element. |
Accessibility
- The element has the timer role. Its text is the time left to the minute, for example “11 days, 4 hours and 12 minutes”, and “less than a minute” at the end.
- It is not a live region: nothing is announced on a tick. Use onDone to announce the end yourself.
- The digits, separators and captions are hidden from screen readers.
What it handles
- 01Counts to a date in days, hours, minutes and seconds, or just the units you ask for; the largest one takes everything above it.
- 02Moves only the digit that changes, and a carry runs from the right: roll it, or flip it like a split-flap board.
- 03Reads the visitor's clock after the page loads, so the server and the browser never disagree, and holds the same space until then.
- 04Keeps every digit in a fixed box, so nothing shifts as it ticks.
- 05Reads as a timer: a screen reader hears the time left to the minute when it gets there, not every second.
- 06Tells you once when the time runs out, with onDone.
States
- First render
- Nothing. A dash holds each digit until the clock is read
- none
- Roll
- The old digit leaves downward, the new one comes in from above, 8px
- 180ms, ease out, at most 40ms behind the digit on its right
- Flip
- The top half folds down, then the new bottom half falls into place
- 120ms and 120ms, ease out, at most 40ms behind
- Run out
- The digits rest at zero and onDone is called
- none
- Reduced motion
- Digits swap at once
- 0ms
| State | What moves | Timing |
|---|---|---|
| First render | Nothing. A dash holds each digit until the clock is read | none |
| Roll | The old digit leaves downward, the new one comes in from above, 8px | 180ms, ease out, at most 40ms behind the digit on its right |
| Flip | The top half folds down, then the new bottom half falls into place | 120ms and 120ms, ease out, at most 40ms behind |
| Run out | The digits rest at zero and onDone is called | none |
| Reduced motion | Digits swap at once | 0ms |
Works with
When to use
When to use
- The days, hours, minutes and seconds to a launch, a deadline or the end of a sale, where the change should be seen in the digit that moves.
When not to use
- A number that changes by data, not by the clock: use Animated Number.
- A short expiry inside a form or an announcement line: use Announcement Bar.
Using with AI
Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:
- Add the Knowns UI Countdown to my app and wire it to my own data.
- I need the days, hours, minutes and seconds to a launch, a deadline or the end of a sale, where the change should be seen in the digit that moves. Set that up with the Knowns UI Countdown.
- Which Countdown props do I need for a minimal setup? Show me a short example.
With the server connected, your assistant calls get_component({ name: "countdown" }) and search_docs({ query: "countdown" }).