Skip to content
caliper ui pro docs

Relative time

A timestamp that reads as a distance from now ("3 minutes ago", "yesterday") and keeps itself current. It is a real time element with the exact moment in its dateTime and the full date as its title, in the reader's language.

Pro
  • Amara Okafor approved the Q4 budget

  • Elias Kim commented on Forma renewal

  • Aiko Tanaka closed INC-311

  • Dev Patel invited 3 people to Finance

When to use

  • Feeds, comments, notifications and run histories, where recency matters more than the clock time.
  • Lists of many rows: every instance on the page shares one 15-second clock.

When not to use

  • Records where the exact time is the fact (an audit trail, an invoice date); show the date.
  • Deadlines; say the date, and use the countdown for the last stretch.

Installation

terminal
pnpm dlx shadcn@latest add @caliper/relative-time

Adds its 2 files to components/ui/, each with its own stylesheet, and installs their packages. Pro installs with your access token, set up once per project. See Pro access. The first part also adds Caliper UI’s tokens; import them once as in Installation.

API reference

RelativeTime

4 props

Also accepts the native props of its root element and a ref.

PropTypeDefaultDescription
date *string | number | Date—
nownumber | Date—A fixed "now", for server rendering, tests and screenshots. Without it the label keeps itself current.
localestring—
numeric"auto" | "always"—`auto` says "yesterday" and "now"; `always` says "1 day ago" and "0 seconds ago".

formatRelative

0 props

No props of its own; it accepts the native props of its root element.

Keyboard

  • No custom key handling; Tab and the native activation keys do the work.

Accessibility

It is built on native elements, so roles and focus come from the browser.

Notes for AI

Give your coding assistant this page as Markdown instead of screenshots: the props, keyboard and examples in one file.

/docs/components/relative-time.md

The index of every part is at /llms.txt.

More in Dates