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';
<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
changedesign<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.
<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.
| Prop | Type | Default | Description |
|---|---|---|---|
label | string | — | What's measured. |
value | ReactNode | — | The figure, formatted. |
change | string | number | — | How it moved: '+12.5%', or a number. |
trend | 'up' | 'down' | 'neutral' | from change | Sets the arrow and color. |
invertTrend | boolean | false | Down is good: green for down, red for up. |
description | ReactNode | — | Under the value, e.g. 'vs last month'. |
icon | ReactNode | — | Beside the label. |
children | ReactNode | — | Below, such as a chart. |
styles | { label?, value?, change?, description? } | — | Slot styles. |
theme, design | As every component. |