Skip to main content

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';
Loading…
<StatsRow items={stats} style={{ width: '100%' }} />

Try the props​

Props
variant
size
density
design
<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.

Loading…
<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.

Loading…
<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'.

Loading…
<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.

Loading…
<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.

Loading…
<View style={{ width: 560, gap: 24 }}>
  <StatsRow items={[]} loading skeletonCount={3} />
  <StatsRow items={[]} error="We couldn't load your figures" onRetry={() => {}} />
</View>

Props​

PropTypeDefaultDescription
itemsStatItem[]—{ 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.
columnsnumberas many as fitTiles per row.
minTileWidthnumber160The narrowest a tile gets before the row wraps.
scrollablebooleanfalseOne row that scrolls sideways.
valueFormat'number' | 'compact' | 'currency' | 'percent''number'
currency / localestring'USD' / device
valueFormatter(value, item) => string—
periodstring'vs last period'What changes compare against.
showTrend / trendVariantboolean / 'line' | 'area' | 'bar'true / 'area'
value / defaultValue / onValueChangestring—Selectable tiles (tabs).
onItemPress(item) => void—Tiles as buttons.
renderItem(info) => ReactNode—Draw a tile's content yourself.
loading / error / onRetry / emptyTitle / emptyDescription / renderEmpty / skeletonCountStates.
density / animate / labels / design / theme / accessibilityLabel / style