Skip to content

components/Stat

import { … } from 'zidane-ui'ui/src/components/Stat.tsx

Components#

DeltaComponent#

Renders a signed change with an arrow, toned by whether the change is good. Its accessible name says the direction in words (Up 12%, Down 5%, No change).

TypeScript
function Delta(props: DeltaProps): Element
Parameters
NameTypeDescription
propsDeltaProps

DeltaProps.

Element
Delta props
NameTypeDefaultDescription
className?string

Extra classes on the root element.

format?(abs: number) => string

Formats the size of the change (no sign). Default: up to one decimal, in the labels' numberLocale.

good?'up' | 'down' | 'none''up'

Which way is good. up: a rise is positive. down: a drop is positive (cost, latency). none: always neutral.

style?CSSProperties

Inline styles on the root element.

tone?DeltaTone

Sets the tone, whatever the sign.

unit?string

Text after the number, for example % or tokens.

valuenumber

The signed change, for example -52 for a drop of 52.

ui/src/components/Stat.tsx:62

StatComponent#

Renders one number: its label, the value large, then the optional line. The label comes first, so a screen reader says what the number is before it.

TypeScript
function Stat(props: StatProps): Element
Parameters
NameTypeDescription
propsStatProps

StatProps.

Element
Stat props
NameTypeDefaultDescription
className?string

Extra classes on the root element.

delta?ReactNode

A change beside the value, usually a Delta.

labelReactNode

What the number is, for example "Cost".

size?StatSize'stat'

stat: the value at the title step (20 px). headline: the figure step (28 px), for the one number that answers a view or a page. At most one per surface.

style?CSSProperties

Inline styles on the root element.

sub?ReactNode

A line under the value, for example "40.6k to 19.7k tokens".

title?string

A native tooltip on the value.

tone?StatTone'neutral'

Colors the value with a status tone.

valueReactNode

The number, formatted.

ui/src/components/Stat.tsx:129

StatRowComponent#

Renders stats side by side as a list, each one an item.

TypeScript
function StatRow(props: StatRowProps): Element
Parameters
NameTypeDescription
propsStatRowProps

StatRowProps.

Element
StatRow props
NameTypeDescription
childrenReactNode

The stats, usually Stats.

className?string

Extra classes on the root element.

columns?2 | 1 | 3 | 4 | 5 | 6

A fixed number of columns. Default: as many as fit, each at least 8rem wide, so a few stats stay in one row and wrap only when narrow.

framed?boolean

Set the row in a tray. Off inside a surface that is already a tray.

label?string

Accessible name of the list.

style?CSSProperties

Inline styles on the root element.

tiles?boolean

Set each stat in its own tile (.zg-tile): a bed one step into the tray it sits on, for the figures of a dashboard. Use it inside a tray, never with framed.

ui/src/components/Stat.tsx:199

Functions#

deltaToneFunction#

The tone a change reads in: a rise is positive when up is good, a drop when down is good.

TypeScript
function deltaTone(value: number, good?: 'up' | 'down' | 'none'): DeltaTone
Parameters
NameTypeDefaultDescription
valuenumber

The signed change.

good?'up' | 'down' | 'none''up'

Which way is good.

ui/src/components/Stat.tsx:50

Constants#

STAT_ROW_COLUMNSConstant#

The default columns: as many as fit, each at least 8rem wide (or the whole row when narrower).

TypeScript
const STAT_ROW_COLUMNS = 'repeat(auto-fit, minmax(min(100%, 8rem), 1fr))'

ui/src/components/Stat.tsx:183

Interfaces#

DeltaPropsInterface#

Props for Delta.

TypeScript
interface DeltaProps
DeltaProps properties
NameTypeDefaultDescription
className?string

Extra classes on the root element.

format?(abs: number) => string

Formats the size of the change (no sign). Default: up to one decimal, in the labels' numberLocale.

good?'up' | 'down' | 'none''up'

Which way is good. up: a rise is positive. down: a drop is positive (cost, latency). none: always neutral.

style?CSSProperties

Inline styles on the root element.

tone?DeltaTone

Sets the tone, whatever the sign.

unit?string

Text after the number, for example % or tokens.

valuenumber

The signed change, for example -52 for a drop of 52.

ui/src/components/Stat.tsx:17

StatPropsInterface#

Props for Stat.

TypeScript
interface StatProps
StatProps properties
NameTypeDefaultDescription
className?string

Extra classes on the root element.

delta?ReactNode

A change beside the value, usually a Delta.

labelReactNode

What the number is, for example "Cost".

size?StatSize'stat'

stat: the value at the title step (20 px). headline: the figure step (28 px), for the one number that answers a view or a page. At most one per surface.

style?CSSProperties

Inline styles on the root element.

sub?ReactNode

A line under the value, for example "40.6k to 19.7k tokens".

title?string

A native tooltip on the value.

tone?StatTone'neutral'

Colors the value with a status tone.

valueReactNode

The number, formatted.

ui/src/components/Stat.tsx:87

StatRowPropsInterface#

Props for StatRow.

TypeScript
interface StatRowProps
StatRowProps properties
NameTypeDescription
childrenReactNode

The stats, usually Stats.

className?string

Extra classes on the root element.

columns?2 | 1 | 3 | 4 | 5 | 6

A fixed number of columns. Default: as many as fit, each at least 8rem wide, so a few stats stay in one row and wrap only when narrow.

framed?boolean

Set the row in a tray. Off inside a surface that is already a tray.

label?string

Accessible name of the list.

style?CSSProperties

Inline styles on the root element.

tiles?boolean

Set each stat in its own tile (.zg-tile): a bed one step into the tray it sits on, for the figures of a dashboard. Use it inside a tray, never with framed.

ui/src/components/Stat.tsx:162

Types#

DeltaToneType#

How a Delta reads: good news, bad news, or neither.

TypeScript
type DeltaTone = 'positive' | 'negative' | 'neutral'

ui/src/components/Stat.tsx:14

StatSizeType#

How large a Stat's value draws.

TypeScript
type StatSize = 'stat' | 'headline'

ui/src/components/Stat.tsx:113

StatToneType#

The status tone of a Stat's value.

TypeScript
type StatTone = 'neutral' | 'info' | 'success' | 'warning' | 'danger'

ui/src/components/Stat.tsx:121