Delta
The mock's .dl: ▲ / ▼ and the change. The arrow is decorative; the words "up" / "down" are read (visually hidden), so the direction never rests on a glyph or a colour.
import { Delta } from '@ergasti/bricks';Examples
Up, down, flat and unknown
A percentage change, coloured and worded for the direction; null means no figure.
Code
import { Delta } from '@ergasti/bricks';
function Directions() {
return (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 20, alignItems: 'center' }}>
<Delta value={9.6} context="vs last 30 days" />
<Delta value={-2.1} />
<Delta value={0} />
<Delta value={null} />
<Delta value={0.4} unit="abs" />
</div>
);
}Tone
By default (tone="auto") a change is green up, red down and grey flat; inside a Tile it takes the tile's ink instead. tone="inherit" always uses the surrounding text colour, for a delta on a coloured surface.
Code
import { Delta } from '@ergasti/bricks';
function Tones() {
return (
<div style={{ display: 'grid', gap: 12 }}>
<div style={{ display: 'flex', gap: 20, alignItems: 'center' }}><code>auto</code><Delta value={9.6} tone="auto" /><Delta value={-2.1} tone="auto" /><Delta value={0} tone="auto" /></div>
<div style={{ display: 'flex', gap: 20, alignItems: 'center', color: 'var(--rasp)' }}><code>inherit</code><Delta value={9.6} tone="inherit" /><Delta value={-2.1} tone="inherit" /><Delta value={0} tone="inherit" /></div>
</div>
);
}What is seen and what is heard
Sighted readers see "▲ 12%", as the mock's .dl; the arrow is hidden from screen readers and a visually hidden "up" / "down" is read instead, so the direction never rests on a glyph or a colour.
Code (not run)
import { Delta } from '@ergasti/bricks';
function SeenAndHeard() {
return (
<div style={{ display: 'flex', gap: 20, alignItems: 'center' }}>
<Delta value={12} />
<Delta value={-3.5} />
</div>
);
}Props
Prop
Type
Labels
Every word this component draws, in both languages. Override one per component and language with BricksProvider labels under the key delta, or with the component's own prop where it has one. A {name} is a value the component fills in.
| Key | English | Arabic |
|---|---|---|
up | up | زيادة |
down | down | نقص |
flat | no change | بدون تغيير |
Design guidance
How the BRICKS design system uses Delta. Written in docs/content/components/Delta.md; the props above are read from the code, which wins where the two disagree.
A change indicator (▲ 9.6 % / ▼ 2 % / "no change") with optional context words; use it under a KPI value or a money figure to show the trend.
Delta is the mock's .dl. The arrow is decorative; the hidden words "up" / "down" are read, so the direction never rests on a glyph or a colour. Positive is green (--ok), negative red (--bad), zero muted, except inside a Tile's delta line or with tone="inherit", where it takes the surrounding ink as the mock does. Numbers are formatted with at most one decimal and kept left to right.
Anatomy
- Wrapper (
span.kit-delta.up|down|flat): 12px 700. - Arrow (
aria-hidden): ▲ or ▼. - Direction words (
.kit-sr): "up" / "down" (Arabic "زيادة" / "نقص"). - Number (
.kit-num,dir="ltr"): absolute value, max 1 decimal, "%" withunit="%". - Context (optional): any node after a space ("vs previous 30 days").
Variants
| Prop | Value | Look | When |
|---|---|---|---|
unit | '%' (default) | "▲ 9.6%" | Growth rates |
unit | 'abs' | "▲ 0.4" | Ratios such as ROI, point changes |
tone | 'auto' (default) | Green up, red down, muted flat; tile ink inside a Tile | Tables, cards, tiles |
tone | 'inherit' | Always the surrounding colour | On coloured surfaces |
States
| State | Trigger | Look |
|---|---|---|
| Up | value > 0 | ▲, --ok |
| Down | value < 0 | ▼, --bad |
| Flat | value === 0 | "no change" / "بدون تغيير", --ink-3, no arrow |
| No value | value === null | Renders nothing |
| In a table | inside .kit-dt | Weight 400 |
Usage
KPI tiles on Analytics (ROI uses an absolute change):
<Tile size="metric" tone="sky" label="ROI" value={<Money value="6.70" />} deco="star"
delta={<Delta value={0.4} unit="abs" context="vs previous 30 days" />} />Under an amount in a table cell:
interface Product { id: number; name: string; sales: string; trend: number | null }
const columns: DataColumn<Product>[] = [
{ key: 'name', label: 'Product', primary: true, render: (p) => p.name },
{ key: 'sales', label: 'Sales', align: 'end', render: (p) => <><b><Money value={p.sales} compact /></b><div><Delta value={p.trend} /></div></> },
];In a key-value fact:
<KeyValue items={[{ key: 'trend', label: 'Trend', value: <Delta value={-3.2} /> }]} />Where it appears
- Brand › Home › 2×2 tiles ("vs previous 30 days").
- Brand › Analytics › four KPI tiles, Best-selling products table (Delta under Sales), product drawer facts.
- Screens: Home, Analytics.
Guidelines
Do
- Pass
nullwhen there is no previous period; never fake a 0. - Add
contextonce per group of tiles so the comparison is clear. - Use
unit="abs"for ratios.
Don't
- Don't colour it yourself; use
tone="inherit"if green/red is wrong for the surface. - Don't round before passing; it formats to one decimal.
RTL and Arabic
- The number is
dir="ltr"; the arrow points up/down so it needs no mirroring. - Arabic hidden words: "زيادة" / "نقص" / "بدون تغيير". Digits stay Latin (
en-USformatting).
Tokens
--ok, --bad, --ink-3.
Accessibility
- Read as "up 9.6% vs previous 30 days": direction in words, not in the glyph or colour.
- The arrow is
aria-hidden.
Found in the source
- ARIA attributes set:
aria-hidden.
Read from the component's source and tests. See Accessibility for the patterns the library follows.
Related
Strong: a bold figure with an ok/bad tone.Tile/KpiCard: hosts with adeltaslot.Money: the figure it usually sits under.
See also: Avatar · AvatarStack · Button · ButtonLink
Source
src/kit/primitives/Delta.tsx (line 28) on GitHub.