Patterns · Data
StatCard
Since v0.0.1
Metric display card showing a KPI value, label, optional delta, and icon.
import { StatCard } from '@nexub/patterns';Examples
Default
With icon
Animated
Category and trend
Compact, absolute change and bad-when-high
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| labelrequired | string | — | Metric name label. |
| valuerequired | React.ReactNode | — | Primary metric value. |
| delta | string | — | Change value (e.g. "+12.5%"). |
| deltaType | 'neutral' | 'increase' | 'decrease' | — | Semantic direction of the delta. |
| sentiment | 'neutral' | 'positive' | 'negative' | derived from `deltaType` (increase → positive, decrease → negative) | Colour of the delta, independent of the arrow. Defaults from deltaType; use it when a decrease is good news (e.g. churn down). |
| icon | React.ReactNode | — | Icon displayed in the card header. |
| category | 'accent' | 'blue' | 'amber' | 'emerald' | 'pink' | 'violet' | 'cyan' | 'red' | 'lime' | — | Puts the icon on a tinted chip of this colour and colours the trend line to match. |
| trend | number[] | — | Recent values, drawn as a small trend line beside the delta. |
| trendLabel | string | — | Accessible summary of the trend. Without it the line is decorative. |
| description | string | — | Additional context below the value. |
| animate | boolean | false | Roll the digits when a number or string value changes (NumberTicker), announced politely. The first render never animates. |
| size | 'sm' | 'md' | 'md' | Since 11.3. sm is the compact tile: less padding and a smaller value. |
| note | React.ReactNode | — | Since 11.3. An extra line inside the tile, under the change. |
| tone | 'default' | 'bad-when-high' | 'default' | Since 11.3. bad-when-high inverts the derived colour, so an increase shows the danger tone (costs, churn, errors). sentiment still wins. |
| change | number | — | Since 11.3. The change as a number: sets the arrow from its sign and the text from changeFormat. Ignored when delta is set. |
| changeFormat | 'percent' | 'absolute' | ((change: number) => string) | 'percent' | Since 11.3. percent takes a fraction (0.125 → +12.5%); absolute signs the number (−12). |
| changeLabel | React.ReactNode | — | Since 11.3. Text after the change, e.g. "vs last month". |
| loading | boolean | false | 10.5: skeletons in place of the value and the line under it; the card keeps its size. |
On iOS & Android: StatCard
@nexub/react-native/patternsAlpha
import { StatCard } from '@nexub/react-native/patterns';
<StatCard label="Active members" value={2840} delta="+12.5%" deltaType="increase" icon={<Users />} category="emerald" trend={weekly} />Web vs mobile
Same tokens and prop names. Where the platforms differ:
| Web | iOS & Android | |
|---|---|---|
| Import | @nexub/patterns. | @nexub/react-native (the main entry). |
| Icon | Any node. | One icon element, e.g. <Wallet />. |
| Pressable | Wrap it in a link. | onPress makes the card one button. |
| Vivid | Lifts on hover. | Lifts while pressed (pressable cards). |
Interactive preview of @nexub/react-native rendered for the web. Native chrome (switches, pickers, Liquid Glass) looks like the platform on a device.
On device

iPhone (iOS simulator)

Pixel (Android emulator)
Screenshots from the latest CI run of the showcase app; the live frame renders the same code for the web.
StatCard props
| Prop | Type | Default | Description |
|---|---|---|---|
| labelrequired | string | — | — |
| valuerequired | React.ReactNode | — | A number or string (rolls with animate), or any node. |
| delta | string | — | The change, already formatted: "+12.5%". |
| deltaType | 'increase' | 'decrease' | 'neutral' | 'neutral' | Direction of the change: sets the arrow (and, by default, the colour). |
| sentiment | 'positive' | 'negative' | 'neutral' | derived from `deltaType` | Whether the change is good or bad, independent of its direction: churn going
down is deltaType="decrease" + sentiment="positive". |
| icon | React.ReactElement<NativeIconProps> | — | One icon element, e.g. <Wallet />. |
| category | CategoryColor | — | Puts the icon on a tinted chip of this colour, and colours the trend line to match. |
| trend | number[] | — | Recent values, drawn as a small trend line beside the delta. |
| trendLabel | string | — | Accessible summary of the trend, e.g. "Last 12 weeks, rising". Without it the line is decorative. |
| description | string | — | — |
| animate | boolean | — | Roll digits when a number/string value changes (NumberTicker); announced politely. |
| loading | boolean | false | Skeletons in place of the value and the line under it; the card keeps its size. |
| onPress | () => void | — | Makes the whole card one pressable target (opens the detail). |
| size | 'md' | 'sm' | 'md' | sm is the compact tile: less padding and a smaller value. |
| note | React.ReactNode | — | An extra line inside the tile, under the change, e.g. "Includes 2 refunds". |
| tone | 'default' | 'bad-when-high' | 'default' | bad-when-high flips the derived colour (an increase shows the danger colour), for
costs, churn and errors. sentiment still wins. |
| change | number | — | The change as a number. Sets the arrow from its sign and the text from changeFormat
(ignored when delta is set). Percent takes a fraction: 0.125 is "+12.5%". |
| changeFormat | 'percent' | 'absolute' | ((change: number) => string) | 'percent' | How change is written. absolute adds the sign to the number. |
| changeLabel | React.ReactNode | — | Text after the change, e.g. "vs last month". |
| style | StyleProp<ViewStyle> | — | — |