Components
StatBlock
Unstable: a headline number with a short label and an optional Delta, three or four in a row. Import it from @nizivo/react/unstable/stat-block.
Examples
Basic
A row of headline numbers in a description list, each a real count.
- colour pairs checked
- 228
- components
- 106
- icons
- 1,880
import type { JSX } from 'react';
import { StatBlock } from '@nizivo/react/unstable/stat-block';
export function StatBlockExample(): JSX.Element {
return (
<dl style={{ display: 'flex', flexWrap: 'wrap', gap: 48, margin: 0 }}>
<StatBlock value="228" label="colour pairs checked" />
<StatBlock value="106" label="components" />
<StatBlock value="1,880" label="icons" />
</dl>
);
}
Import
import { StatBlock } from '@nizivo/react/unstable/stat-block';
// Once per app (Getting started), after
// @nizivo/tokens/tokens.css and @nizivo/react/css/base.css
import '@nizivo/react/css/stat-block.css';Static or interactive
Server. No client JavaScript. How to choose.
Use
value is the number, formatted, in tabular figures; label says what it counts; delta takes a
Delta. Each block is a term and its value, so put a row of them in a
<dl>. Only real, sourced numbers: never round up for effect.
Props
Server component Renders data-slot="stat-block" with the class nz-stat-block. Props: StatBlockProps. Source: src/unstable/stat-block/stat-block.tsx.
| Name | Type | Default | Description |
|---|---|---|---|
delta | ReactNode | – | Under the label: a Delta. |
labelrequired | ReactNode | – | What it counts: "colour pairs checked". |
render | RenderProp<Record<string, never>> | – | Must render a |
valuerequired | ReactNode | – | The number, formatted: "228", "12.4k". |
- Also takes every attribute of
<div>exceptchildren. (Omit<ComponentPropsWithRef<"div">, "children">)
render takes an element, or, in client code, a function of the props and no state.
Other exports
StatBlockPropstypeimport type { StatBlockProps } from '@nizivo/react/unstable/stat-block'The props of
StatBlock, listed above.
Data attributes and slots
Style parts by class (.nz-<slot>) and state by data attribute. Attribute meanings come from contracts/vocabulary.json.
| Slot | Rendered by | Data attributes |
|---|---|---|
stat-block.nz-stat-block | StatBlockroot (takes render) | none |
stat-block-label.nz-stat-block-label | StatBlockinner element (CSS only) | none |
stat-block-value.nz-stat-block-value | StatBlockinner element (CSS only) | none |
CSS hooks
Set a hook on the component's class or any ancestor to restyle it without specificity games; leave it unset for the default shown.
This stylesheet reads no public hook.
Layers: nz.components. Classes: .nz-stat-block, .nz-stat-block-delta, .nz-stat-block-label, .nz-stat-block-value.
Tokens this stylesheet reads (6)
--nz-font-body-m, --nz-font-numeric-display, --nz-space-1, --nz-text-primary, --nz-text-secondary, --nz-tracking-numeric-display
Accessibility
Nothing in this component takes focus or keyboard input.
Keyboard
None.