Skip to content
satin

Relative time

When something happened, as "5 min ago" today and the clock time before, kept current.

Tara Mendes commented on the offer

Installation

Terminal
npm i @uisatin/ui
Import
import { RelativeTime } from '@uisatin/ui/relative-time'

About 12.3 kB of JavaScript, minified and gzipped, with what it imports (React aside). The stylesheet is one file for every component.

First time with Satin? Set it up once, styles and fonts included, with the installation guide.

API Reference

The RelativeTime component renders a time element with dateTime set: relative today ("now", "5 min ago", "2 hr ago"), the clock time before that, and the date too with withDate. Every RelativeTime on the page reads one clock that ticks every 30 seconds while any is mounted, and only the ones whose text changed render. Words and formats follow dateLocale in SatinLabels. useRelativeClock(text) gives your own text from the same clock (text gets the time in ms), and dateTimeFormat and relativeTimeFormat hand out shared Intl formatters.

PropTypeDefault
at
Datestringnumber
—
withDate
boolean
false
className
string
—
ref
Ref<HTMLElement>
—
...props
ComponentProps<'time'>

Other attributes go to <time>

—

Accessibility

A native time element with a machine-readable dateTime. The short text ("5 min ago") is aria-hidden; screen readers hear the full date and time from a visually hidden span instead ("Monday, November 16, 2026 at 9:40 AM"), which doesn’t change while the page is open. It isn’t a live region: a tick that changes the short text announces nothing.