Skip to content

Countdown

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
Used for
  • Launch day timer
  • Waitlist closes
  • Sale ends
  • Event starts
  • Beta window

Examples

Variant

A minute rollover

When the seconds pass 00 the minute moves with them.

Sizes and units

Installation

npx knowns-ui@latest add countdown
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

torequired
Date | number
The moment it counts to, or ms since the epoch.
units
("days" | "hours" | "minutes" | "seconds")[]
Defaultall 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>>
Defaulttrue
A caption under each unit: Days, Hours, Minutes, Seconds, your own words, or none.
separators
boolean
Defaultfalse
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.

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

  1. 01Counts to a date in days, hours, minutes and seconds, or just the units you ask for; the largest one takes everything above it.
  2. 02Moves only the digit that changes, and a carry runs from the right: roll it, or flip it like a split-flap board.
  3. 03Reads the visitor's clock after the page loads, so the server and the browser never disagree, and holds the same space until then.
  4. 04Keeps every digit in a fixed box, so nothing shifts as it ticks.
  5. 05Reads as a timer: a screen reader hears the time left to the minute when it gets there, not every second.
  6. 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

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

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" }).

Need help?

Stuck on Countdown, or found something off? We read every message.