Components
Metric
Headline-number card with unit, delta, status and comparison slots, usable as a tab that opens a chart.
import { Metric } from "@openperf/deft";
<Metric.Card delta="▲ 12%" label="Response time" tone="warning" unit="ms" value={128} />;When to use
| Need | Component |
|---|---|
| Key number in a card, with a comparison, sparkline or chart | Metric |
| Small label and value in the flow of a page | Stat |
| Proportion bar on its own | Meter |
| Ordinary tabs | Tabs |
Anatomy
<Metric.Card /> {/* standalone card */}
<Metric.Root> {/* Tabs.Root */}
<Metric.List> {/* grid of tabs */}
<Metric.Tab name="latency" /> {/* a Metric.Card that works as a tab */}
</Metric.List>
<Metric.Panel value="latency" /> {/* Tabs.Panel */}
</Metric.Root>name on Metric.Tab must equal the value of its Metric.Panel. Metric.List is a single-column grid: set the number of columns through className and name it with aria-label.
Chart cards
backdrop sits behind the card content and fades out toward the left, so a cover-size Sparkline does not fight with the value. It is hidden from assistive technology: do not put information there that is not also in the value or the delta.
A card without value is a titled frame: put a Chart in the children and its legend in actions.
Tabs
Metric.Tab takes every Metric.Card prop. Metric.Root and Metric.Panel are the Tabs parts and take their props, such as defaultValue, value and onValueChange.
API
Metric.Card
value, unit and delta render as given: format the number and the change yourself. unit, delta and aside render only with value.
Prop
Type
Metric.Tab
Prop
Type