Prepared Docs

Prepared Docs

⌘K

    Loading navigation…

User

  1. Components
  2. Metric Card
  3. API and Development

Metric Card

API and Development

View Source
Submit Issue

MetricCard is exported from @prepared911/ui-core. It composes CardHeader and CardContent. It does not export MetricValue, MetricChange, or private chrome helpers.

Props

Name

Type

Default

Description

label

LocalizedMessage

—

Localized metric name shown in the card header.

value

number | LocalizedMessage

—

Numeric value to format and optionally animate.

animation

(MetricAnimationOptionsBase & { live?: AnimatedNumberLive.Off; }) | (MetricAnimationOptionsBase & { ...; })

—

—

announcement

LocalizedMessage

—

—

aria-label

LocalizedMessage

—

Accessible name for the action target.

controls

ReactNode

—

Interactive header controls forwarded to CardHeader.controls.

delta

MetricCardDelta

—

—

formatOptions

NumberFormatOptions

—

Intl options forwarded to localized formatNumber.

headingLevel

HeadingLevel

HeadingLevel.H3

Semantic heading rank for the header title. The title always uses BodyLarge strong typography.

loading

boolean

—

—

loadingLabel

LocalizedMessage

—

—

onClick

MouseEventHandler<HTMLButtonElement>

—

Activates the stretched card action target.

selected

boolean

—

Maps to aria-pressed on the action target.

subtitle

LocalizedMessage

—

Optional localized supporting copy under the value.

trailing

ReactNode

—

Decorative trailing visual. Mounted aria-hidden in a 2.8rem-high box only when a renderable node is provided.

Storybook

Interactive examples and edge cases for this component are in Storybook.

Default
Stat With Delta
Decrease Success
Custom Heading Level
Loading
With Controls
Selected Action
Animated Value And Delta
Delta Direction Matrix

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.
animation / announcementsee belowOpt-in value odometer via AnimatedNumber.
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

Numeric values may opt into AnimatedNumber:

  • animation.from and animation.duration control the entrance reel.
  • animation.live={AnimatedNumberLive.Polite} requires localized announcement.
  • Localized string values cannot animate.

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