UnflowUI
Components

Stat

A KPI tile with a label, a preformatted value, an optional delta and caption, laid out in rows with StatGroup.

Overview

Stat shows one number with its label and, optionally, how it changed. The value is rendered as given: format numbers, money and units before passing them. The delta colour follows sentiment, so a value that goes up can still read as bad (e.g. spend). StatGroup lays several tiles out in a responsive row.

By default the tile sits in a Card; set bare to render it without one.

Import

import { Stat, StatGroup } from '@unflowio/ui/components/Stat';

Props

PropTypeDefaultDescription
labelReactNode—Required. What the number measures
valueReactNode—Required. The value, already formatted
suffixReactNode—Text after the value, in a smaller size (e.g. "of 86")
deltaStatDelta—Change against a reference period
captionReactNode—Context for the delta, or a standalone note (e.g. "vs September")
iconReactNode—Decorative icon before the label
loadingboolean—Shows skeletons instead of the value and delta
trendReactNode—A small chart (e.g. a sparkline) under the value
bareboolean—Renders without the surrounding Card
variant'muted' | 'raised''muted'Variant of the surrounding Card

StatDelta:

FieldTypeDescription
valuestringRequired. Formatted change (e.g. "+9%", "€282.55")
direction'up' | 'down' | 'flat'Required. Drives the arrow
sentiment'positive' | 'negative' | 'neutral'Drives the colour. Defaults to positive for up, negative for down and neutral for flat

StatGroup takes standard div props and lays its children out in a grid.

Basic usage

Active people

74of 86

Increase +9%vs September

<Stat
  label="Active people"
  value="74"
  suffix="of 86"
  delta={{ value: '+9%', direction: 'up' }}
  caption="vs September"
/>

Sentiment

Override sentiment when the direction alone gives the wrong colour.

Runs

9,412

Increase +12%vs September

Spend

€2,184.60

Increase +€282vs September

Failed runs

12

Decrease -40%vs September

Workspaces

4

No change 0vs September

<StatGroup>
  <Stat label="Runs" value="9,412" delta={{ value: '+12%', direction: 'up' }} />
  <Stat label="Spend" value="€2,184.60" delta={{ value: '+€282', direction: 'up', sentiment: 'negative' }} />
  <Stat label="Failed runs" value="12" delta={{ value: '-40%', direction: 'down', sentiment: 'positive' }} />
  <Stat label="Workspaces" value="4" delta={{ value: '0', direction: 'flat' }} />
</StatGroup>

Loading and bare

Runs

Runs

9,412

Month to date

<Stat label="Runs" value="9,412" delta={{ value: '+12%', direction: 'up' }} loading />
<Stat label="Runs" value="9,412" caption="Month to date" bare />

Customization (slotProps)

Slot PropPropsDescription
labelBaseHTMLProps<HTMLParagraphElement>The label
valueBaseHTMLProps<HTMLParagraphElement>The value row
deltaBaseHTMLProps<HTMLParagraphElement>The delta row
cardPartial<ICard>Props for the surrounding Card

Accessibility

  • The delta direction is also announced as visually hidden text, so it doesn't rely on the arrow or the colour.
  • While loading, the tile sets aria-busy and the skeletons are hidden from assistive technology.