Stat card
One headline tile: a small label with an optional explanation, a large tabular figure, a quieter line with an optional trend, and a top-right action. Per-part classNames, and an optional selectable mode (a toggle button with aria-pressed) for tiles that filter a list.
Component: A piece you place inside your own screens: a table, a form, a card or a dialog. You decide the layout around it. Pages vs components
Works with Dolfin’s SDK context, with appearance and behaviour you can customise. Requires DolfinProvider.
Installation
Needs the Dolfin registry token. The CLI copies the source into your app.
bunx --bun shadcn@4.23.0 add @dolfin/base-stat-cardAlso installs: base-info-hint, ui-base-stat-card.
Usage
import { StatCard } from "@/components/dolfin/base/stat-card";
// Place it anywhere inside your <DolfinProvider>.
<StatCard label={label} value={value} />Renders inside DolfinProvider (set it up once). It renders the data you pass as props.
API reference
| Prop | Type | Description |
|---|---|---|
label required | string | |
value required | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | |
hint | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | A sentence explaining the figure, behind an InfoHint beside the label. |
sub | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | |
trend | "up" | "down" | Adds an arrow to the sub line; `trendTone` decides whether it is coloured. |
trendTone | "neutral" | "semantic" | `semantic`: up reads as good news, down as bad. `neutral`: arrows only. |
action | string | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re… | Top-right action, e.g. an Ask agent button. |
reserveActionSpace | boolean | Keep the label clear of the action corner even without an action, so tiles in a row line up. |
onSelect | () => void | Makes the tile a toggle (a button with `aria-pressed`), e.g. to filter a list by this figure. |
selected | boolean | |
className | string | |
classNames | StatCardClassNames | |
slot | string | `data-slot` of the root, so module tiles keep their own (`ap-stat-card`, ...). |
data-testid | string |
Customisation
Without editing the source, you can change:
- Class names
classNameclassNames.rootclassNames.labelclassNames.valueclassNames.subclassNames.actionclassNames.selected
Or edit the installed file directly: it is your code. See theming for colours and fonts.
Files
Written to your app by the install command:
components/dolfin/base/stat-card.tsx71 lines