RelativeTime
Relative timestamp that re-renders as the clock moves (for example "2m ago"), for log tables, activity feeds, and comment threads.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
date | Date | — | The instant to display relative to now. |
format | RelativeStyle | "narrow" | "narrow" | "short" | "long". Narrow is the log-table format (3m); long renders as prose. |
live | boolean | true | Stop re-rendering as the clock moves. Disable for static snapshots. |
showTitle | boolean | true | Show the absolute timestamp on hover via the title attribute. |
cutoffMs | number | — | Past this age in milliseconds, show the absolute date instead of a relative string. |
Examples
All formats
Future date
Past dates at different intervals
import { RelativeTime } from "@solarius/onset";
import type { RelativeTimeProps, RelativeStyle } from "@solarius/onset";