DefaultNumericFormatStyleUnitLocaleDateAttributeSync
<div nve-layout="column gap:sm">
<nve-format-relative-time>2020-01-15T12:00:00.000Z</nve-format-relative-time>
<nve-format-relative-time>2024-06-15T12:00:00.000Z</nve-format-relative-time>
<nve-format-relative-time>2025-12-01T12:00:00.000Z</nve-format-relative-time>
</div>
2020-01-15T12:00:00.000Z
2024-06-15T12:00:00.000Z
2025-12-01T12:00:00.000Z
Edit Example
Formats a date/time value as localized relative text using the Intl.RelativeTimeFormat API. Renders inside a semantic time element.
Options mirror the Intl.RelativeTimeFormat API. When unit is 'auto', the component selects the best unit based on the time difference.
<div nve-layout="column gap:sm">
<nve-format-relative-time numeric="always" unit="year">2025-01-15T12:00:00.000Z</nve-format-relative-time>
<nve-format-relative-time numeric="auto" unit="year">2025-01-15T12:00:00.000Z</nve-format-relative-time>
</div>
2025-01-15T12:00:00.000Z
2025-01-15T12:00:00.000Z
Edit Example
Numeric formatting: 'always' | 'auto'. When 'auto', enables natural language forms such as 'yesterday' instead of '1 day ago'.
Numeric Description always auto
<div nve-layout="column gap:sm">
<nve-format-relative-time format-style="long">2020-01-15T12:00:00.000Z</nve-format-relative-time>
<nve-format-relative-time format-style="short">2020-01-15T12:00:00.000Z</nve-format-relative-time>
<nve-format-relative-time format-style="narrow">2020-01-15T12:00:00.000Z</nve-format-relative-time>
</div>
2020-01-15T12:00:00.000Z
2020-01-15T12:00:00.000Z
2020-01-15T12:00:00.000Z
Edit Example
Formatting length: 'long' | 'short' | 'narrow'. Controls verbosity (such as '3 days ago' vs '3d ago'). Maps to Intl.RelativeTimeFormat style option.
FormatStyle Description long short narrow
<div nve-layout="column gap:sm">
<nve-format-relative-time unit="day">2020-01-15T12:00:00.000Z</nve-format-relative-time>
<nve-format-relative-time unit="month">2020-01-15T12:00:00.000Z</nve-format-relative-time>
<nve-format-relative-time unit="year">2020-01-15T12:00:00.000Z</nve-format-relative-time>
</div>
2020-01-15T12:00:00.000Z
2020-01-15T12:00:00.000Z
2020-01-15T12:00:00.000Z
Edit Example
Time unit: 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year' | 'auto'. Use 'auto' to let the component select the most appropriate unit based on the time difference.
Unit Description second minute hour day week month year auto
<div nve-layout="column gap:sm">
<nve-format-relative-time locale="de-DE">2020-01-15T12:00:00.000Z</nve-format-relative-time>
<nve-format-relative-time locale="ja">2020-01-15T12:00:00.000Z</nve-format-relative-time>
<nve-format-relative-time locale="fr-FR">2020-01-15T12:00:00.000Z</nve-format-relative-time>
</div>
2020-01-15T12:00:00.000Z
2020-01-15T12:00:00.000Z
2020-01-15T12:00:00.000Z
Edit Example
Language tag (such as en-US, de-DE). Defaults to document.documentElement.lang or browser default.
Locale Description string default
<nve-format-relative-time date="2020-01-15T12:00:00.000Z"></nve-format-relative-time>
Edit Example
Date attribute input for values supplied by JavaScript or bound data. By default, the component formats text content, which also serves as the SSR fallback, and date wins when both are present.
<nve-format-relative-time sync>2020-01-15T12:00:00.000Z</nve-format-relative-time>
2020-01-15T12:00:00.000Z
Edit Example
When present, auto-updates the displayed relative time at appropriate intervals.
Sync Description true false