---
title: "Countdown"
description: "The time left until a date, as short text or as boxes, a line, or large digits. It can pause, and it shows your text when the time runs out."
url: https://gelatinui.com/components/countdown
markdown_url: https://gelatinui.com/components/countdown.md
access: free
install: "npx shadcn@latest add @gelatin-ui/countdown"
registry_item: https://gelatinui.com/r/countdown.json
version: "2026-11-09"
index: https://gelatinui.com/llms.txt
docs_index: https://gelatinui.com/docs/llms.txt
---

# Countdown

> The time left until a date, as short text or as boxes, a line, or large digits. It can pause, and it shows your text when the time runs out.

Page: https://gelatinui.com/components/countdown

## When to use it

Best for: The time left until a moment, as short text or as segments in boxes, in a line, or as digits.

- Use it with no children for short text, such as 2d 9h.
- Use `CountdownSegment` parts with the `box`, `inline`, or `digits` variant for a timer.
- Use `CountdownEnded` and `onEnd` to show text or act when the time runs out.
- Use `paused` to stop the shown value. The end time does not move.

## When not to use it

- For the time since a past moment, use [Time Ago](https://gelatinui.com/components/time-ago.md).
- For a length of time that does not count down, use [Duration](https://gelatinui.com/components/duration.md).

## Notes for agents

- `date` is the end moment. A missing or invalid date shows the empty text.
- The root has `role="timer"`. Name it with `aria-labelledby` and a visible label.
- One shared timer wakes each second, on the second, so the seconds do not drift.
- `trim` (on by default) hides days and hours at 0.
- Pass `now` for a fixed time in tests and screenshots.

## Anatomy

```text
Countdown
├─ CountdownSegment (0..n)
├─ CountdownSeparator (0..n)
├─ CountdownEmpty (0..n)
└─ CountdownEnded (0..n)
```

## API reference

### Countdown

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `date` | `DateLike \| null` |  | The end: a `Date`, an ISO string, epoch milliseconds, or a `DateValue` (`#/lib/date-parse`). `null`, `undefined`, and a value that is not a date show the empty text. |
| `children` | `ReactNode` |  | `CountdownSegment` and `CountdownSeparator` parts, `CountdownEnded` (what shows at 0), and `CountdownEmpty`, the words of no date. With no segments, the root renders the text ("2d 9h"). |
| `length` | `DurationLength` | "narrow" | Text only: the `style` of `Intl.DurationFormat`. `narrow` (default) "2d 9h", `short` "2 days, 9 hr", `long` "2 days, 9 hours". Not named `style`: a component does not take the CSS inline style. |
| `maxUnits` | `1 \| 2 \| 3 \| 4` | 2 | Text only: the number of units, from the biggest that is not 0. Default 2 ("2d 9h", "42m 17s"). |
| `trim` | `boolean` | true | Hide the leading segments at 0 and the separator after each ("42:17" under one hour). Default `true`. |
| `paused` | `boolean` | false | Stop the shown value and mute the numbers (`data-paused`). The end does not move. |
| `onEnd` | `function` |  | Called once when the time is up, also on mount when `date` is past. |
| `now` | `DateLike` |  | A fixed now for tests and stories. With it, no timer runs. |
| `locale` | `string` |  | The BCP 47 language tag: words, digits, and `dir`. Default: the `DisplayLocaleProvider` locale, else `"en-US"` (`useDisplayLocale`), never the browser language. |

### CountdownSegment

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `"box" \| "digits" \| "inline"` | "box" |  |
| `unit` | `"days" \| "hours" \| "minutes" \| "seconds"` |  | The unit this segment shows. The biggest unit in the root takes the rest (57 hours with no days segment). |

### CountdownSeparator

No props of its own: `className`, `children`, and every other prop go to the element it renders.

### CountdownEmpty

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `data-slot` | `string` |  | The `data-slot` of the root: the item's own slot (`"time-ago"`). Default `"empty-value"`. |

Also takes every prop of Base UI `UseRender`: https://base-ui.com/react/components/use-render

### CountdownEnded

No props of its own: `className`, `children`, and every other prop go to the element it renders.

## Styling

| Part | Slot | States | CSS variables | Tokens |
| --- | --- | --- | --- | --- |
| Countdown | `countdown` | `data-ended`, `data-variant` | `--countdown-time` |  |
| CountdownSegment | `countdown-segment` | `data-paused`, `data-trimmed` | `--countdown-time` |  |
| CountdownSeparator | `countdown-separator` | `data-trimmed`, `data-variant` | `--countdown-time` |  |
| CountdownEmpty | `countdown-empty` |  |  |  |
| CountdownEnded | `countdown-ended` | `data-ended` | `--countdown-time` |  |

## Usage

Set the end date and add one segment for each unit that you show, with a separator between them.

```tsx title="sale-countdown.tsx"
import {
  Countdown,
  CountdownEnded,
  CountdownSegment,
  CountdownSeparator,
} from "@/components/ui/countdown";

export function SaleCountdown() {
  return (
    <Countdown date="2026-11-28T23:59:00+01:00">
      <CountdownEnded>The sale has ended</CountdownEnded>
      <CountdownSegment unit="days" />
      <CountdownSeparator />
      <CountdownSegment unit="hours" />
      <CountdownSeparator />
      <CountdownSegment unit="minutes" />
      <CountdownSeparator />
      <CountdownSegment unit="seconds" />
    </Countdown>
  );
}
```

## Compose

Rules:

- Compose the parts (`compose-parts`): Build each item from its named parts as children, and pass your text and icons in as parts.
- Every state is designed (`every-state`): Give each view of data its loading, empty, and error states: a skeleton in the final layout, an `Empty` with an illustration and one next action, and an error that says what failed and how to retry.

## Add it

```bash
npx shadcn@latest add @gelatin-ui/countdown
```

It adds 32 registry items: 31 files, 6070 lines, and the npm packages `@base-ui/react`, `@internationalized/date`, `clsx`, `motion`, `react-aria-components`, `tailwind-merge`, `tailwind-variants`.

## Built on

- [Rolling Number](https://gelatinui.com/components/rolling-number.md)

## For AI agents

- Every item, one file: https://gelatinui.com/llms.txt
- MCP server (`search_items`, `get_item`, `get_install_plan`): https://gelatinui.com/mcp

## Related

- [Duration](https://gelatinui.com/components/duration.md)
- [Time Ago](https://gelatinui.com/components/time-ago.md)
- [Clock](https://gelatinui.com/components/clock.md)

## Motion

| Part | Motion |
| --- | --- |
| Digits | none · the digits change at once, with no fade |
