How late or early a vehicle or departure runs, as a short figure in the delay's colour, such as "+3 min", with the same thing said in words to a screen reader.
When to use
Use Delay for how late or early one vehicle or departure runs, beside stronger text such as the departure time.
| Use instead | When |
|---|---|
| SeverityLabel | The delay is a disruption on a whole line |
Kongens Nytorv
Metro M1, M2 and M3.
Props
| Name | Type | Default | Description |
|---|---|---|---|
minutes* | number | null | (required) | The delay in minutes: positive when late, negative when early, 0 on time, null when no real-time data says (timetable only, no signal). Rounded to the nearest whole minute. |
minutesUnitLabel | string | The locale's | Overrides "min", the unit after the figure |
minutesLateLabel | string | The locale's | Overrides "min late", heard after the number when late |
minutesEarlyLabel | string | The locale's | Overrides "min early", heard after the number when early |
onTimeLabel | string | The locale's | Overrides "On time" |
delayUnknownLabel | string | The locale's | Overrides "Delay unknown", heard in place of "—" |
className | string | — | Reaches the root; className is merged after pn-Delay |
style | CSSProperties | — | Reaches the root; className is merged after pn-Delay |
ref | Ref<HTMLSpanElement> | — | Reaches the root element |
minutes (required)number | null, default (required)- The delay in minutes: positive when late, negative when early,
0on time,nullwhen no real-time data says (timetable only, no signal). Rounded to the nearest whole minute. minutesUnitLabelstring, default The locale's- Overrides "min", the unit after the figure
minutesLateLabelstring, default The locale's- Overrides "min late", heard after the number when late
minutesEarlyLabelstring, default The locale's- Overrides "min early", heard after the number when early
onTimeLabelstring, default The locale's- Overrides "On time"
delayUnknownLabelstring, default The locale's- Overrides "Delay unknown", heard in place of "—"
classNamestring, default —- Reaches the root;
classNameis merged afterpn-Delay styleCSSProperties, default —- Reaches the root;
classNameis merged afterpn-Delay refRef<HTMLSpanElement>, default —- Reaches the root element
Use it
import { Delay } from '@mylder/perron'Ask your agent
search_docs({ query: "Delay" })Keyboard and ARIA
Delay is text: it takes no focus, and no key does anything. A caller who makes it a link or button through render brings that element's own keys.
| Key | Does | From |
|---|---|---|
| none | Delay is not focusable or operable | Perron |
| Element | Role | Accessible name from | States announced |
|---|---|---|---|
root | none: a generic <span> | Not named; its text is read in place, as part of the row or sentence it sits in | none |
value and unit | hidden, aria-hidden="true" | Not read, except "On time", which is read as shown (CR-3) | none |
label | text | The owned strings: "3 min late", "1 min early", "Delay unknown" | none |
The visible figure is aria-hidden, with a VisuallyHidden label saying the delay in words: the number without its sign and then "min late" or "min early" ("3 min late", "1 min early"), and "Delay unknown" in place of "—", while "On time" is read from the visible text. A screen reader reads "+3 min" as "plus 3 min" and skips or spells "—", so the ear would get less than the eye, and an aria-label on a role-less <span> is not allowed.
What axe won't catch, from the contract, each with how this component meets it:
- Everything the eye is told, the ear is told, for every shape each prop accepts: the colour and sign say late, slight, early or on time; the label says "N min late" or "N min early", "On time" is read as shown, and
nullsays "Delay unknown". In forced colours the colour goes, and the sign and words still carry it. - Every landmark and named region has an accessible name: none here; Delay is inline text.
- Every default label can be overridden:
minutesUnitLabel,minutesLateLabel,minutesEarlyLabel,onTimeLabelanddelayUnknownLabel. - Every shape the type accepts renders, in every variant:
minutesis a number ornull; positive, negative, zero, fractional (rounded),NaNand infinite (both unknown, CR-1) all render, and a story'splaytest covers each kind. - A hidden copy kept for animation is
aria-hidden, and a collapsed region isinert: none here; Delay does not animate. The visible figure isaria-hiddenbecause the label speaks for it, not for animation. - Native semantics first: a
<span>, with no role and no ARIA beyondaria-hiddenon the figure the label replaces. - Focus moves in reading order and returns on close: Delay takes no focus.
- Every target is at least
size.target-minsquare: no target; Delay is not pressed. - Loops stop when the system asks for less motion: none here; Delay has no motion.
Owned strings
Every word Delay shows or announces is its own; the caller gives only minutes. The number is never part of a string: it renders as its own text run beside the word, so the dictionaries stay plain strings (CR-3).
| Key | English | Override | Seen or heard where |
|---|---|---|---|
minutesUnit | "min" | minutesUnitLabel | unit, seen after a signed figure, "+3 min"; aria-hidden |
minutesLate | "min late" | minutesLateLabel | label, heard after the number when late: "3 min late" |
minutesEarly | "min early" | minutesEarlyLabel | label, heard after the number when early: "1 min early" |
onTime | "On time" | onTimeLabel | value, seen and heard when minutes rounds to 0 |
delayUnknown | "Delay unknown" | delayUnknownLabel | label, heard in place of "—" when minutes is null |
No key in packages/perron/src/locale/en.ts says any of these, so all five are new, each with a JSDoc line like its neighbours.
"On time" and "Delay unknown" join the data-state and delay words table in docs/content-design.md, with their Danish, Swedish and Norwegian, so every screen says a delay the same way; content design says delays always use the words in that table, and its test then holds the locale files to them. "min", "min late" and "min early" stay out of it, as parts of a number's phrase rather than words a screen shows on their own.
Do and don't
For a caller using the component, with the reason. Each row is a rule: a must row's Don't is never right, a should row's needs a reason, and Checked by says what catches the Don't in a caller's code.
| Rule | Level | Do | Don't | Checked by |
|---|---|---|---|---|
| DD-1 | must | Pass minutes={null} for a timetable-only or no-signal vehicle, because no real-time data says how late it is. | Pass 0 when the delay is unknown: "On time" claims more certainty than the data has. | review |
| DD-2 | must | Pass the delay in minutes, and let Delay round, sign and colour it. | Format the figure yourself and put it in a Text in a delay colour: the words for the ear and the data-delay kind go missing. | review |
| DD-3 | must | Set Delay beside stronger text, such as the departure time, because color.transit.delay.unknown is too faint to stand alone. | Use Delay alone as a row's only content when it may be unknown: "—" in that colour misses 4.5:1 by design. | review |
| DD-4 | must | Announce a changed delay in the screen's own polite live region, once, when its kind changes. | Wrap Delay in a live region that reads every minute's change: it floods the screen reader. | review |
| DD-5 | should | Use color.transit.severity.delay and its label for a delay disruption on a line. | Use Delay for a line's disruption: it says how late one vehicle or departure runs. | review |