Skip to content

Duration

Free

A length of time as text: short units (1m 8s), a clock (1:08), or words (1 minute, 8 seconds). It can count up or down live.

  • React Aria
  • React 19
  • Tailwind CSS 4

Added Nov 9, 2026 · MIT + Commons Clause

Playground

Loading the preview

Props

Pass the length in seconds. Put a DurationEmpty inside for a step that has no time yet.

build-steps.tsx

Duration

<time>
PropTypeDefaultDescription
secondsnumber—The length in seconds. A negative value or NaN shows as 0. With since or until, it is the value once the clock stops (live false), or the empty text.
durationMsnumber—The length in milliseconds, in place of seconds: 2400 is "2.4s".
valuestring—The length as an ISO 8601 duration, in place of seconds: "PT1H30M", "P1DT2H". Years and months have no fixed length, so "P1M" is invalid and shows empty.
sinceDateLike—A live count-up: whole seconds since this time (a Date, ISO text, or epoch milliseconds) on the shared second clock (useElapsedSeconds), so only this part renders on a tick. A muted box of about the final width shows before hydration.
untilDateLike—A live count-down: whole seconds left until this time, rounded up.
livebooleantrueRun the since or until clock. Default true; false shows seconds (the end value).
nowDateLike—A fixed now for since and until (tests, stories, a frozen view): no clock runs, and it shows before hydration too.
onEnd—Called once when an until clock reaches 0 while it runs.
kind"clock""units""words""units"The look of the text. Default units.
length"long""narrow""short""long"The words of kind="words": long (default) "1 minute, 8 seconds", short "1 min, 8 sec", narrow "1m 8s".
fractionDigits"auto"01"auto"The fraction digits of units. Default auto: one digit under 10s ("2.4s"), none from 10s on ("14s"). A live clock always shows whole seconds, so it ticks "1s", "2s", "3s".
animatedbooleantrueRoll the digits that change on the Rolling Number (units and clock). Default true. false prints plain text: for long lists and table cells. Words never roll.
localestring—The BCP 47 locale ("de-DE"). Default: the DisplayLocaleProvider locale, else "en-US".
childrenReactNode—DurationEmpty, the words of no value, and DurationEnded, what shows in place of the time when an until clock is at 0 ("Done", "Expired"). Only the one for the current state draws.
...props<time> attributes—Every other attribute goes to the <time>, with a ref.

DurationEmpty

<div>
PropTypeDefaultDescription
data-slotstring—The data-slot of the root: the item's own slot ("time-ago"). Default "empty-value".
From Base UIUseRenderBase UI docs
render—Allows you to replace the component's HTML element with a different tag, or compose it with another component. Accepts a ReactElement or a function that returns the element to render.
...props<div> attributes—Every other attribute goes to the <div>, with a ref.

DurationEnded

<span>
PropTypeDefaultDescription
...props<span> attributes—Every other attribute goes to the <span>, with a ref.
  • Use kind="units" for 1m 08s.
  • Use since to count up, and until to count down.
  • Set animated to roll the digits.
  • For a time point such as 5 minutes ago, use Time Ago.
  • For a timer with buttons, use a Button.

The time element holds the exact ISO length.

Digits
panel · 260ms · the digits roll when `animated` is on

Built with

Installs with Duration

Components
Rolling Number
  1. AddedDuration, with Rolling Number.
Open the release