# Metric Card

KPI stat card for dashboards and analytics: a metric name, a large tabular value, an optional outline badge with a trend-up or trend-down icon and screen-reader label, and an optional description line.

Component · Metrics · https://01orbital.dev/docs/components/metric-card

## Installation

```bash
npx shadcn@latest add @01orbital/metric-card
```

## Usage

```tsx
import { MetricCard } from "@/components/card/metric-card"

// The demo's words. Change copy here, not in the markup.
const COPY = {
  name: "Total visitors",
  value: "248.5k",
  change: "12.4%",
  up: "Up",
  period: "vs last period",
} as const

export default function MetricCardDemo() {
  return (
    <>
      {/* 276px: one column of the four-up dashboard row this card is made
          for (72rem less three 16px gaps, over four). The card sets its own
          width: a centred grid item otherwise shrinks to its content. */}
      <MetricCard
        className="w-full max-w-[17.25rem]"
        name={COPY.name}
        value={COPY.value}
        change={{ value: COPY.change, trend: "up", label: COPY.up }}
        description={COPY.period}
      />
    </>
  )
}
```

This example installs with everything it uses:

```bash
npx shadcn@latest add @01orbital/metric-card-demo
```

## API reference

A card that shows one metric on a dashboard: its name, its value in large type, an optional change badge and an optional line of text below.

It takes no children. `className` and other props land on the `Card`.

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `size?` | `"default" \| "sm"` |  | The stock `Card` size: `default` puts 24px of space around and between the card's parts, `sm` 16px. |
| `name` | `ReactNode` |  | The metric's name, shown as a small muted label at the top. |
| `value` | `ReactNode` |  | The figure itself, in large type with tabular numerals. |
| `change?` | `{ value: ReactNode; trend: "up" \| "down"; label: string; }` |  | A change badge in the top-right corner. `value` is its visible text, `trend` picks an up or down arrow, and `label` is read to screen readers before the value, since the arrow is hidden from them. |
| `description?` | `ReactNode` |  | A line of muted text under the value. |

## Dependencies

Requires these pieces. The CLI adds each one that is missing and won't replace a file you already have unless you choose to:

- [Badge](https://01orbital.dev/docs/components/badge)
- [Card](https://01orbital.dev/docs/components/card)

The shadcn parts here are their Base UI versions, and this piece uses Base UI's API. A Radix version you already have won't work with it.

npm: `@phosphor-icons/react`

## Examples

- **Metric Card Dispute Rate** (`@01orbital/metric-card-dispute-rate`): Example of the Metric Card: a falling dispute rate stat on a navy ground, with a note and two supporting figures. The metric card is a KPI stat tile for dashboards and analytics.
