Skip to main content

Stat

A key figure with its label and how it moved: the tiles at the top of a dashboard. The change is green when it's good and red when it's bad, with an arrow so color isn't the only cue.

import { Stat } from 'patine-ui';
Loading…
<Grid minColumnWidth={180} gap="md" style={{ maxWidth: 640 }}>
  {KPIS.map(({ icon, ...kpi }) => (
    <Card key={kpi.label} style={{ padding: 16 }}>
      <Stat {...kpi} description="vs last month" icon={<Icon name={icon} />} />
    </Card>
  ))}
</Grid>

Try the props​

Props
change
design
<Stat
label="Revenue"
value="$48,210"
description="vs last month"
change="+12.5%"
/>

Example: today in a shop​

A shop's home screen: four numbers for the chosen period, each with its change against the period before. For refunds a rise is bad, so invertTrend colors it red.

Loading…
<VStack gap="md" style={{ width: '100%', maxWidth: 640 }}>
  <SegmentedControl items={[{ label: 'Today', value: 'today' }, { label: 'Last 7 days', value: 'week' }]} value={range} onValueChange={setRange} style={{ alignSelf: 'flex-start' }} />
  <Grid minColumnWidth={150} gap="md">
    {DATA[range].map(({ icon, ...kpi }) => (
      <Card key={kpi.label} style={{ padding: 16 }}>
        <Stat {...kpi} description={range === 'today' ? 'vs yesterday' : 'vs the week before'} icon={<Icon name={icon} />} />
      </Card>
    ))}
  </Grid>
</VStack>

Trend​

The trend comes from change: a leading - or − (or a negative number) is down, zero is neutral, anything else is up. Set trend to say it yourself. For figures where down is good, such as costs, churn or load time, set invertTrend.

With a chart​

Children go below the figure, such as a Sparkline.

Designs​

brand and web draw a bold figure with colored change text, as shadcn's dashboard cards. iOS and Material put the change in a tinted pill.

Accessibility​

The tile is one element, read as a sentence: "Revenue, $48,210, up 12.5%, vs last month". The arrow and the word "up" or "down" carry the trend without color.

Props​

Also takes View props.

PropTypeDefaultDescription
labelstring—What's measured.
valueReactNode—The figure, formatted.
changestring | number—How it moved: '+12.5%', or a number.
trend'up' | 'down' | 'neutral'from changeSets the arrow and color.
invertTrendbooleanfalseDown is good: green for down, red for up.
descriptionReactNode—Under the value, e.g. 'vs last month'.
iconReactNode—Beside the label.
childrenReactNode—Below, such as a chart.
styles{ label?, value?, change?, description? }—Slot styles.
theme, designAs every component.