Axon 911 Frontend DocsAxon 911 Frontend Docs
Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Components
  2. Metric Card
  3. API and Development

Metric Card

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
MetricCard is exported from @prepared911/ui. It composes CardHeader and CardContent. It does not export MetricValue, MetricChange, or private chrome helpers.
Props
NameTypeDefaultDescription
labelLocalizedMessage | DisplayValue—The metric's name. Always a heading, so the dashboard outline names every tile.
valuenumber | LocalizedMessage | DisplayValue | null—The metric. Each change rolls the digits that changed. The metric as copy or data. No value.
announcementLocalizedMessage—Copy a polite live region announces after a change of value has settled. Not announced on first paint. Text does not roll. An empty value does not roll.
aria-labelLocalizedMessage | DisplayValue—A static card has no action to name. Accessible name of the action ("Show queue depth"). The overlay button carries it.
aria-pressedboolean—A static card has no action to toggle. Toggle state. Omit for a plain action; true paints the accent edge.
childrenundefined—The card is a closed preset. It takes no children.
classNamestring—Classes appended after the generated classes. Put overrides in @layer chroma.overrides.
controlsReactNode—Interactive group in the header, such as a SegmentedControl. An action card holds no other interactive control.
deltaMetricCardDelta—The change beside the value. An empty value has nothing to compare.
emptyLabelLocalizedMessage—A numeric value has no empty-state copy. A text value has no empty-state copy. Names the gap for assistive technology ("No calls today").
emptyTextLocalizedMessage—A numeric value has no empty-state placeholder. A text value has no empty-state placeholder. Visible placeholder. Omit it for an em dash.
formatOptionsNumberFormatOptions—Intl.NumberFormat options: currency, percent, units, compact notation, fraction digits, sign display. Text is not formatted. An empty value is not formatted.
fromnumber—Entrance: the first paint shows this number, then the digits roll to value. Read on mount only. Text does not roll. An empty value does not roll.
headingLevelCardHeadingLevelCardHeadingLevel.H3Heading element for the label. The label's type role is fixed, so the rank follows the page outline.
loadingboolean—Replace the value, delta, subtitle and sparkline with a skeleton and mark the body busy. Show the value and delta.
loadingLabelLocalizedMessage—The one loading status assistive technology reads. Visually hidden: the skeleton is the visible cue. A card that is not loading has no loading copy.
localestring—BCP 47 locale for the value and the delta. Defaults to the runtime locale, so a server-rendered page that must match the client passes it explicitly.
onClickMouseEventHandler<HTMLButtonElement>—A static card has no action. Runs when the card is activated by pointer, Enter or Space.
prefixTextAffix—Localized copy before the number, or a function of the number that returns it. Include any separating space. Text is not formatted. An empty value is not formatted.
refRef<HTMLDivElement>—Ref to the card's root element.
rollbooleantrueRoll the digits of the value and the delta to each new number. false renders them as plain formatted text and drops from and announcement.
sizeMetricCardSizeMetricCardSize.DefaultPadding and value type.
sparklineReactNode—Slot for a sparkline from Charts. Mounted aria-hidden in a fixed-height box under the value, so it must repeat nothing the value, delta and subtitle do not already say.
subtitleLocalizedMessage | DisplayValue—Supporting copy under the value, such as the period the value covers.
suffixTextAffix—Localized copy after the number, or a function of the number that returns it. Include any separating space. Text is not formatted. An empty value is not formatted.
Storybook
Interactive examples and edge cases for this component are in Storybook.
DefaultOpens in a new tab
Exact contract
NameTypeNotes
labelLocalizedMessageRequired. Rendered as CardHeader title.
valueLocalizedMessage or numberAlways NumericDisplay (2.4rem) with tabular figures, rendered as a span. Numeric values use formatNumber. Prelocalized messages skip number formatting and animation.
subtitleLocalizedMessageOptional.
formatOptionsIntl.NumberFormatOptionsNumeric values only.
headingLevelHeadingLevelOptional. Semantic rank for the header title. Default HeadingLevel.H3. Does not change value typography.
from / announcement / rollsee belowNumeric values roll through Text value mode.
deltaMetricCardDeltaMutually exclusive with trailing. Optional visual-only delta animation.
trailingReactNodeDecorative, aria-hidden, 2.8rem box. Omitted when unset or a boolean. Forbidden when delta is set.
loadingbooleanRequires loadingLabel.
controlsReactNodeForwarded to CardHeader.controls. Mutually exclusive with clickable props.
onClick / selected / aria-labelsee interactionActivates the stretched card action target. Requires all three when clickable.
Value animation
A numeric value rolls through Text from @prepared911/ui/text:
  • from is the entrance number. It is read on mount only.
  • announcement is localized copy spoken after a change of value settles.
  • roll={false} renders the formatted number as plain text.
  • A value that is already copy does not roll.
Delta magnitudes accept visual-only animation without polite live regions.
Delta model
Direction and tone are separate fields. Direction selects the arrow; tone colors the delta label and arrow fill only.
directionArrowMagnitudeTone
Increase / Decrease / UnchangedYesRequired numeric valueRequired
Introduced / UnavailableNoUnrepresentableUnrepresentable; use label
There is no card-level tone or statusLabel.
Default tile
Stat card with delta
Animated value and delta
Clickable tile
Loading
Decorative trailing chart
Use ChartFamilyDemos on the visualization-charts page. MetricCard trailing is aria-hidden; the label and value are the equivalent. Do not pass trailing when delta is set.
Previous
Metric Card / Usage
Next
Metric Card / Accessibility
On this page
Props
Storybook
Exact contract
Value animation
Delta model
Default tile
Stat card with delta
Animated value and delta
Clickable tile
Loading
Decorative trailing chart