dolfindevelopers

Stat card

ComponentFoundationsSDK + UI

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

Choose your integration

Works with Dolfin’s SDK context, with appearance and behaviour you can customise. Requires DolfinProvider.

Loading preview…

Installation

Needs the Dolfin registry token. The CLI copies the source into your app.

Terminal
bunx --bun shadcn@4.23.0 add @dolfin/base-stat-card

Also installs: base-info-hint, ui-base-stat-card.

Usage

screen.tsx
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

PropTypeDescription
label requiredstring
value requiredstring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…
hintstring | 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.
substring | 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.
actionstring | number | bigint | boolean | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<ReactNode> | React.Re…Top-right action, e.g. an Ask agent button.
reserveActionSpacebooleanKeep the label clear of the action corner even without an action, so tiles in a row line up.
onSelect() => voidMakes the tile a toggle (a button with `aria-pressed`), e.g. to filter a list by this figure.
selectedboolean
classNamestring
classNamesStatCardClassNames
slotstring`data-slot` of the root, so module tiles keep their own (`ap-stat-card`, ...).
data-testidstring

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.tsx 71 lines