Spark
The mock's spark(): 120 × 46, stroke 2.5, non-scaling.
import { Spark } from '@ergasti/bricks';Examples
Area trend
A filled line over a period with a few x labels. Every chart takes a label (its accessible name) and draws a calm "no data" state for an empty series.
Code
import { AreaTrend } from '@ergasti/bricks';
import { mock } from './sample-data';
function Trend() {
return (
<div style={{ maxWidth: 700, background: 'var(--card)', borderRadius: 22, padding: 16 }}>
<AreaTrend data={mock.SERIES.sales} xLabels={['14 Oct', '28 Oct', '13 Nov']} label="Sales, last 30 days" />
</div>
);
}Spark and mini bars
The small charts that sit inside a tile. A null in the series is a gap.
Code
import { MiniBars, Spark } from '@ergasti/bricks';
import { mock } from './sample-data';
function Small() {
return (
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 24, alignItems: 'flex-end' }}>
<Spark data={mock.SERIES.sales} tone="lime" label="Sales" />
<Spark data={[...mock.SERIES.roi.slice(0, 10), null, ...mock.SERIES.roi.slice(11)]} tone="sky" label="ROI with a gap" />
<MiniBars data={mock.SERIES.orders.slice(-12)} tone="rasp" label="Orders" />
<Spark data={[]} label="Empty" />
</div>
);
}Tones
tone picks the line and fill colour: lime, rasp, butter or sky.
Code
import { AreaTrend } from '@ergasti/bricks';
import { mock } from './sample-data';
function Tones() {
return (
<div style={{ display: 'grid', gap: 12, gridTemplateColumns: 'repeat(auto-fit, minmax(260px, 1fr))' }}>
{(['rasp', 'sky'] as const).map((tone) => (
<div key={tone} style={{ background: 'var(--card)', borderRadius: 22, padding: 16 }}>
<AreaTrend data={mock.SERIES.orders} tone={tone} label={`Orders, ${tone}`} />
</div>
))}
</div>
);
}Props
Prop
Type
Design guidance
How the BRICKS design system uses Spark. Written in docs/content/components/Spark.md; the props above are read from the code, which wins where the two disagree.
A small sparkline (120 × 46) that shows the shape of a series; use it in a KPI Tile's chart slot.
Spark is the mock's spark(): a single polyline with a 2.5px non-scaling round stroke, scaled to its box. It is memoised, so a tile grid re-rendering does not redraw every line. A null value splits the line into runs (a gap is never a zero), and a visually hidden table carries every value for screen readers. The v3 mock styles it as .tile .spark (bottom-end of the tile, 46 % wide, 46px tall); Tile's chart slot places it there.
Anatomy
- SVG (
svg.kit-spark, viewBox0 0 120 46,preserveAspectRatio="none", fills its box,aria-hidden). - Line per run of known points: stroke in the tone colour, 2.5px, round caps and joins; 4px headroom top and bottom.
- Hidden series table (
.kit-sr): caption =label, rows 1…n with the value or "—".
Variants
tone | Stroke | When |
|---|---|---|
'rasp' (default) | --rasp | Orders, the raspberry tile |
'lime' | --spark-lime | Sales, the lime tile |
'butter' | --spark-butter | Commission, the butter tile |
'sky' | --sky-ink | ROI, the sky tile |
Match the tone to the Tile's tone so the line reads on its tint.
States
| State | Trigger | Look |
|---|---|---|
| Default | numbers in data | One continuous line |
| Gap | null entries | The line breaks at each gap |
| Empty | data=[] | Muted "No data yet" / "لسه مفيش بيانات" (12px), no SVG |
| Single point | one value | Nothing visible (a one-point polyline); the table still has the value |
Types
Series (data): ReadonlyArray<number | null>.
Usage
<Tile tone="lime" label="Sales" value={<Money value="312400.00" compact />} delta={<Delta value={9.6} />}
chart={<Spark data={SERIES.sales} label="Sales, last 30 days" tone="lime" />} />In the 4-up KPI grid, one tone per tile:
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4, 1fr)', gap: 16 }}>
<Tile tone="lime" label="Sales" value={<Money value="312400.00" compact />} delta={<Delta value={9.6} />} chart={<Spark data={SERIES.sales} label="Sales" tone="lime" />} />
<Tile tone="rasp" label="Orders" value="1,284" delta={<Delta value={7.9} />} chart={<MiniBars data={SERIES.orders.slice(-12)} label="Orders" />} />
<Tile tone="butter" label="Commission" value={<Money value="46900.00" compact />} delta={<Delta value={9.7} />} chart={<Spark data={SERIES.commission} label="Commission" tone="butter" />} />
<Tile tone="sky" label="ROI" value={<Money value="6.70" />} delta={<Delta value={0.4} />} chart={<Spark data={SERIES.roi} label="ROI" tone="sky" />} />
</div>Outside a Tile, give it a sized box:
<div style={{ width: 140, height: 46 }}><Spark data={[4, 6, null, 9, 12]} label="ROI" tone="sky" /></div>Where it appears
- Brand › Home and Analytics › KPI tiles: the mock's
.tile .sparkslot (the v3 screens mostly show the tiledecoinstead; Spark is the chart option of the same slot). - Kit gallery; no dedicated screen.
Guidelines
Do
- Size the container; Spark fills 100 % × 100 %.
- Keep 7 to 30 points; fewer looks jagged, more becomes noise at 120px.
- Use the same
toneas the surrounding Tile.
Don't
- Don't add axes, labels or tooltips; it is a shape, the number is in the Tile.
- Don't use it as the only place a figure is shown.
RTL and Arabic
- The line does not mirror: time runs left to right in both languages.
- Inside a Tile the slot sits at the inline end, so it moves to the left in Arabic.
Tokens
--rasp, --spark-lime, --spark-butter, --sky-ink (stroke per tone), --ink-3 (empty text).
Accessibility
- The SVG is
aria-hidden; the hidden<table>(captionlabel) reads every point, "—" for gaps. - Not focusable.
- The stroke colour carries no meaning on its own; the Tile's value and Delta do.
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
MiniBars: the same slot as bars (discrete counts, such as orders).AreaTrend: the full-width trend chart.Tile: the host that positions it.
See also: BarChart · Gauge · HBars
Source
src/kit/patterns/Charts.tsx (line 58) on GitHub.