HapplyUI

Components

Stat Strip

A row of figures between a hairline above and below. Each section shows an icon, a label and its value, with an optional pill for the change against the previous period.


Installation

bunx @happlyui/cli@latest add stat-strip

Dependencies

Registry dependencies

These are automatically installed when you add this component.

  • happly-ui-utils

Usage

import * as KeyIcon from "@/components/ui/key-icon"
import * as StatStrip from "@/components/ui/stat-strip"

<StatStrip.Root>
  <StatStrip.Item
    icon={<KeyIcon.Root icon={<RiTimeFill />} />}
    label="Label"
    value={3654}
  />
</StatStrip.Root>

Examples

Default

Stroke key icons with a tinted glyph. Number values are formatted with toLocaleString.

New
11,435
Review
3,654
Waiting
3,654
Declined
3,654
Approved
3,654
Fulfilled
1,112
<StatStrip.Root>
  <StatStrip.Item
    icon={<KeyIcon.Root icon={<RiTimeFill className="text-warning-base" />} />}
    label="Review"
    value={3654}
  />
</StatStrip.Root>

Coloured icons

Any KeyIcon style works in the icon slot, such as lighter with a colour.

Category A
15
Category B
2
Category C
12
Category D
5
Category E
3
Category F
0
<StatStrip.Item
  icon={<KeyIcon.Root style="lighter" color="red" icon={<RiPlayFill className="text-error-dark" />} />}
  label="Category A"
  value={15}
/>

With delta

Pass a pre-formatted string for currency, and a delta for a change pill. Leave delta out and the section has no pill.

Metric A
$96,000.00+5%
Metric B
$6,000.00+5%
Metric C
$24,000.00-3%
Metric D
$14,000.00
<StatStrip.Item
  icon={<KeyIcon.Root icon={<RiMoneyDollarCircleLine />} />}
  label="Metric A"
  value="$96,000.00"
  delta={5}
/>

Rounded zero

A change smaller than half a percent displays as a neutral 0% pill.

Small increase
1200%
Small decrease
1200%
<StatStrip.Item icon={<KeyIcon.Root icon={<RiStarLine />} />} label="Small increase" value={120} delta={0.3} />

API Reference

StatStrip.Root

The row. Its sections share the width equally.

PropTypeDefaultDescription

StatStrip.Item

One section. Its icon and figure sit centred in it, and every section but the first gets a divider before it.

PropTypeDefaultDescription
iconReactNode-Usually a KeyIcon
labelstring-The figure's name
valuenumber | string-A number is formatted with toLocaleString; a string is shown as given
deltanumber | null-Change against the previous period, in percent. Leave out, or pass null, for no pill
trend'up' | 'down' | 'flat'sign of rounded deltaColours the pill. Pass your data source's own direction when it has one; a displayed 0% stays neutral

Previous
Performance Card