Components
Performance Card
One border around a subject and its numbers. The header holds the media, title, meta row and stat tiles; anything after it, such as a table, carries the header's inset.
Installation
bunx @happlyui/cli@latest add performance-card
Dependencies
npm packages
@remixicon/react@^4.6.0
Registry dependencies
These are automatically installed when you add this component.
happly-ui-utils
Usage
import * as PerformanceCard from "@/components/ui/performance-card"
<PerformanceCard.Root>
<PerformanceCard.Header media={<PerformanceCard.Media className="size-36" />}>
<PerformanceCard.Title>Person name</PerformanceCard.Title>
<PerformanceCard.Meta>In-person meeting</PerformanceCard.Meta>
<PerformanceCard.Stats>
<PerformanceCard.Stat value={214} label="Bookings" />
<PerformanceCard.Metric value={240} label="Tickets sold" delta={-5.4} comparison="vs last week" />
</PerformanceCard.Stats>
</PerformanceCard.Header>
</PerformanceCard.Root>
Examples
Default
A wide thumbnail, a truncating title, a meta row of icons, text and badges, and tiles of a figure and its label. The media takes a width only, so it fills the header's height and its bottom edge lines up with the tiles.
Session title
<PerformanceCard.Header
media={<PerformanceCard.Media className="w-[270px]" />}
action={<Button.Root>Details</Button.Root>}
>
<PerformanceCard.Title className="text-title-h6 truncate">Session title</PerformanceCard.Title>
</PerformanceCard.Header>
With sub-labels
Sub-labels sit on the title's baseline, each behind a rule. The media falls back to its placeholder when there is no image.
Person name
Rolename@example.com<PerformanceCard.Title sublabels={['Role', 'name@example.com']}>
Person name
</PerformanceCard.Title>
With a change
Use Metric instead of Stat when the figure carries its change against another period. The arrow gives the direction, green up and red down, and the percentage is unsigned.
Event name
<PerformanceCard.Metric
value={240}
label="Total tickets sold"
delta={-5.4}
comparison="vs last week"
/>
With content below
Root has no padding, so content under the header sets its own. Match the header's 24px inset and a table's header band sits inside the card, as the design draws it.
Session title
| Name | Region | Views |
|---|---|---|
| Person one | Montreal, Canada | 1,240 |
| Person two | Vancouver, Canada | 980 |
| Person three | Toronto, Canada | 612 |
<PerformanceCard.Root>
<PerformanceCard.Header>…</PerformanceCard.Header>
<div className="px-6 pb-6">
<Table.Root>…</Table.Root>
</div>
</PerformanceCard.Root>
API Reference
PerformanceCard.Root
The card's single border. No padding of its own, so each part sets its own: the header's 24px inset is what content below it should match.
| Prop | Type | Default | Description |
|---|
PerformanceCard.Header
The padded top of the card. 24px padding, 16px between the media and the rest.
| Prop | Type | Default | Description |
|---|---|---|---|
media | ReactNode | - | A Media, to the left of the children |
action | ReactNode | - | Sits top right, level with the title. Usually a Button |
PerformanceCard.Media
The thumbnail or avatar. Give it a width and it fills the header's height, so its bottom edge lines up with the stat tiles. A square avatar can take size- instead.
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | - | The image |
alt | string | '' | The image's description |
placeholder | ReactNode | - | Shown instead of the image when there is no src |
PerformanceCard.Title
The card's name. Size it with className: text-title-h6 for a wide card, the default text-label-lg for a compact one.
| Prop | Type | Default | Description |
|---|---|---|---|
sublabels | ReactNode[] | [] | Sit on the title's baseline, each behind a rule |
PerformanceCard.Rule
The 1px rule between a title's sub-labels, or between groups in the meta row.
| Prop | Type | Default | Description |
|---|
PerformanceCard.Meta
The wrapping row of icons, text and badges under the title, 8px below it.
| Prop | Type | Default | Description |
|---|
PerformanceCard.Stats
The row of tiles, 12px under the meta row. Tiles share the width equally.
| Prop | Type | Default | Description |
|---|
PerformanceCard.Stat
One tile: the figure and its label.
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | string | - | A number is formatted with toLocaleString; a string is shown as given |
label | string | - | What the figure counts |
PerformanceCard.Metric
A tile that also carries its change against another period. Takes Stat's props too.
| Prop | Type | Default | Description |
|---|---|---|---|
delta | number | - | Change against the comparison period, in percent. The arrow carries the direction, so the percentage is shown unsigned |
comparison | string | - | What the delta compares against, such as "vs last week" |