MetricsCard

Fiddle
A stat tile: title, counted value, change and refresh state.
Page views48.2k+12% vs last 30 days

Usage

The import, then a use to start from. Both copy as they are.

Import
import { MetricsCard } from "@/components/web-analytics/MetricsCard";
Example
<MetricsCard    title="Page views"    value={48200}    isLoading={isLoading}    error={error}    change={{        label: "+12%",        direction: "up",        tone: "positive",        description: "43,100 in the previous 30 days"    }}/>

When to use

Use it for

  • One number per tile, with its title and how it moved against the previous period.
  • value={null} with an emptyLabel when there's no number to show; suffix for a unit such as %.
  • isRefreshing dims the old number while a new range loads, instead of blanking it.

Avoid

  • A comparison that isn't fair: leave change out rather than show it.
  • Several numbers in one tile. Give each its own.

Accessibility

Checks

  • change.description is read with the label, so the comparison makes sense without the color.

API

Read from each component's stories, the same source as COMPONENTS.md, and kept in step by check:design-system.

MetricsCard

Its stories don't declare argTypes, so no props are listed. The variants show its states.
VariantsDefaultPercentageEmptyWithChangeNegativeChangeNeutralChangeRefreshingLoadingErrorState

Keep going