Stats row Pro
A dashboard's key figures in a row. Each tile shows its value, how it changed (green when it's good news, red when it isn't, with an arrow so color isn't the only cue) and an optional trend. The row wraps to fit, or scrolls sideways on phones. Tiles can be buttons, or tabs that pick which figure a chart shows. Each tile is read as one sentence: "Revenue, $48,250, up 18% vs last period".
import { StatsRow } from '@patine-ui/pro';
<StatsRow items={stats} style={{ width: '100%' }} />
Try the props
variantsizedensitydesign<StatsRow
items={stats}
value={selected}
onValueChange={setSelected}
/>
Example: a newsletter's dashboard
A newsletter's last issue: subscribers, opens, clicks and unsubscribes against the issue before, each read the right way round, so fewer unsubscribes shows as good news. Press a tile to see what it counts.
<View style={{ width: '100%', gap: 8 }}> <StatsRow items={STATS} period="vs issue #141" onItemPress={(item) => setPicked(item.key)} value={picked ?? undefined} /> <Text size="sm" color="textSecondary">{picked ? STATS.find((s) => s.key === picked)?.description : 'Issue #142 · sent Tuesday 07:00'}</Text> </View>
Values and changes
A number value is formatted with valueFormat ('number', 'compact', 'currency' or 'percent' for fractions), per tile or for the row; a string is shown as it is. Give previous and the change is worked out, or delta as a ratio (0.12 is +12%). Set good: 'down' for figures where falling is good news, like churn or costs. valueFormatter formats every number your way.
Tiles that switch a chart
Give value and onValueChange (or defaultValue) and the tiles become tabs, as Stripe's dashboard does: the chosen one is marked and the chart under it follows.
<View style={{ width: 520, gap: 16 }}> <StatsRow items={stats} value={metric} onValueChange={setMetric} /> <LineChart data={data} xKey="month" series={[{ key: metric, label: metric === 'revenue' ? 'Revenue' : 'Orders' }]} valueFormat={metric === 'revenue' ? 'currency' : 'number'} height={180} /> </View>
Variants and sizes
variant is 'cards', 'plain', 'divided' (one bordered strip split by hairlines, as Tremor draws it) or 'tinted'; the default follows the design. size is 'sm', 'md' or 'lg'.
<View style={{ width: 560, gap: 24 }}> <StatsRow items={stats} variant="divided" /> <StatsRow items={stats} variant="plain" size="lg" /> <StatsRow items={stats} variant="tinted" size="sm" density="compact" /> </View>
Live figures
Tiles rise in once when they mount; after that, new values update in place without moving the layout.
<StatsRow style={{ width: 420 }} items={[ { key: 'live', label: 'Visitors right now', value: visitors, previous: 1800, icon: 'users' }, { key: 'conv', label: 'Conversion', value: 0.034, delta: 0.08, valueFormat: 'percent', icon: 'target' }, ]} />
States
loading shows a skeleton of the tiles (skeletonCount of them), error an error with onRetry, and an empty items its empty state.
<View style={{ width: 560, gap: 24 }}> <StatsRow items={[]} loading skeletonCount={3} /> <StatsRow items={[]} error="We couldn't load your figures" onRetry={() => {}} /> </View>
Props
| Prop | Type | Default | Description |
|---|---|---|---|
items | StatItem[] | — | { key, label, value, previous?, delta?, good?, period?, icon?, trend?, description?, valueFormat?, disabled? } |
variant | 'cards' | 'plain' | 'divided' | 'tinted' | the design's | |
size | 'sm' | 'md' | 'lg' | 'md' | The figures' size. |
columns | number | as many as fit | Tiles per row. |
minTileWidth | number | 160 | The narrowest a tile gets before the row wraps. |
scrollable | boolean | false | One row that scrolls sideways. |
valueFormat | 'number' | 'compact' | 'currency' | 'percent' | 'number' | |
currency / locale | string | 'USD' / device | |
valueFormatter | (value, item) => string | — | |
period | string | 'vs last period' | What changes compare against. |
showTrend / trendVariant | boolean / 'line' | 'area' | 'bar' | true / 'area' | |
value / defaultValue / onValueChange | string | — | Selectable tiles (tabs). |
onItemPress | (item) => void | — | Tiles as buttons. |
renderItem | (info) => ReactNode | — | Draw a tile's content yourself. |
loading / error / onRetry / emptyTitle / emptyDescription / renderEmpty / skeletonCount | States. | ||
density / animate / labels / design / theme / accessibilityLabel / style |