For AI agents: the complete documentation index is available at https://wallarm.github.io/design-system/llms.txt, the full documentation bundle is available at https://wallarm.github.io/design-system/llms-full.txt, and this page is available as Markdown at https://wallarm.github.io/design-system/components/format-duration.md.

FormatDuration

Prints how long something took in its two largest units — 1h 30m, 30m 23s, 45s — so a column of run times stays short and comparable. When smaller units are dropped, the exact duration sits in a tooltip behind a dashed underline. value takes milliseconds or an ISO 8601 duration (PT2M13S); formatDuration() returns the same text as a string.

Source · Storybook

Usage

import { FormatDuration } from '@wallarm-org/design-system/FormatDuration';

Examples

Truncated

Two units are shown; the rest moves into the tooltip, so 1h 4m 30s reads 1h 4m with the exact figure on hover. tooltip={false} drops the tooltip and the underline.

Iso duration

An ISO 8601 duration from an API contract renders as is, without converting it first.

Null value

null and undefined render an em dash with 'No data' on hover; a negative or unparsable value renders a bare em dash.

Inherit typography

typography='inherit' renders a plain span, so the duration takes its font, size, weight and colour from the parent.

Props

PropTypeDefaultDescription
titlestring | undefined
defaultCheckedboolean | undefined
defaultValuestring | number | readonly string[] | undefined
autoFocusboolean | undefined
idstring | undefined
tabIndexnumber | undefined
relstring | undefined
onChangeChangeEventHandler<T, Element> | undefined
value *DurationValueMilliseconds, or an ISO 8601 duration ("PT2M13S"). null/undefined renders an em dash with a "No data" tooltip; a negative or unparsable value renders a bare em dash.
tooltipboolean | undefinedWhether to show the exact duration in a tooltip when smaller units were dropped ("1h 4m" → "1h 4m 30s"). Default: true.
typography"inherit" | "default" | undefineddefault'default' renders 14px body text; 'inherit' takes font, size and colour from the parent. Default: 'default'.
data-testidstring | undefined