Theme
RelativeTime
Displays relative time with auto-updating
Start Here
Start from the smallest working snippet, then move to interactive examples and the full API contract below.
Styled quick start
Copy this entrypoint first. It includes the imports required to get the component on screen.
svelte
<script lang="ts">
import '@dryui/ui/themes/default.css';
import '@dryui/ui/themes/dark.css';
import { RelativeTime } from '@dryui/ui';
</script>
<RelativeTime>Content</RelativeTime>Import options
Root package
ts
import { RelativeTime } from '@dryui/ui'Per-component subpath
ts
import { RelativeTime } from '@dryui/ui/relative-time'Customize
Use the interactive examples to see common variants, states, and composition patterns before building your own.
Default
svelte
<RelativeTime date={fiveMinutesAgo} />Various Times
svelte
<script lang="ts">
const fiveMinutesAgo = new Date(Date.now() - 5 * 60 * 1000);
const twoHoursAgo = new Date(Date.now() - 2 * 60 * 60 * 1000);
const yesterday = new Date(Date.now() - 24 * 60 * 60 * 1000);
const nextWeek = new Date(Date.now() + 7 * 24 * 60 * 60 * 1000);
</script>
<RelativeTime date={fiveMinutesAgo} />
<RelativeTime date={twoHoursAgo} />
<RelativeTime date={yesterday} />
<RelativeTime date={nextWeek} />Compose
The full API contract lives here: props, CSS variables, and the public data attributes you can target when styling.
| Prop | Type | Default | Required | Bindable |
|---|---|---|---|---|
date | Date | string | number | — | ✓ | — |
locale | string | — | — | — |
updateInterval | number | — | — | — |
Forwards <time> attributes via rest props. Common examples: datetime, id, aria-label.