StellarUI

<stellar-relative-time>

Localized relative-time formatter with optional live updates.

Properties

Preview

Markup

Copy
<stellar-relative-time date="2024-01-01T12:00:00.000Z"></stellar-relative-time>

API

Complete props, events, slots, and implementation notes for the shipped relative-time formatter.

Props

PropTypeDefaultNotes
datestring''
formatlong | short | narrowlong
numericauto | alwaysauto
livebooleanfalse

Events

EventSourceNotes
custom eventsnonestellar-relative-time is display-only and does not emit custom events.

Slots

SlotNotes
noneThis component has no slots. It renders one semantic <time> element.

Notes

  • The public tag is `stellar-relative-time`, and it keeps the shipped surface: `date`, `format`, `numeric`, and `live`.
  • It renders one semantic `<time>` element using the platform `Intl.RelativeTimeFormat` API.
  • `date` accepts ISO 8601 strings in markup, while the host `.date` property also accepts a `Date` object.
  • When `live` is true, all connected instances share one timer and update together once per second instead of each component scheduling its own interval.
  • `lang` on the host changes the formatter locale; otherwise the component falls back to the document language and then the browser locale.