Calm motion: animations on this site only fade, with no movement
Sparkline
A tiny inline chart for a row, a card or a sentence
A trend drawn at the size of a word: the last days of a metric in a table row, a stat card, a list item. It shows the shape, not the values, so pair it with the number it summarizes. For a chart the reader studies (axes, tooltips, several series) use Chart.
Line, bar and win/loss
| Metric | Last 9 days | Shape |
|---|---|---|
| Visits | rising | |
| Profit | up and down | |
| Results | 6 wins, 3 losses |
type="line"(withfillanddot, if you want them).type="bar"grows from zero, so negatives hang below.type="winloss"ignores the size of a value and draws only whether it was up, down, or flat.- It is an image to assistive tech, named with a summary: the count, first and last value, low and high (or wins and losses for win/loss). Give it a
labelso it reads "Visits: 9 values, from 12 to 40…", and aformatto put units on the numbers. - Color is a token name (
chart-2,success,danger) or any CSS color.negativeColorcolors the values below zero. Color is never the only signal: the bars sit above or below the line. - Size is in pixels (
width,height). There is no hover, so nothing to reach by keyboard.
Usage
ts
import { BlessSparkline } from "blessing-ui";API
Props
| Name | Type | Default | Description |
|---|---|---|---|
data* | number[] | — | |
type | "bar" | "line" | "winloss" | "line" | `line`, `bar`, or `winloss` (every value drawn as a same-height win above or loss below the middle) |
width | number | 120 | |
height | number | 28 | |
color | string | "chart-1" | a token name (`chart-2`, `success`, `danger`…) or any CSS colour |
negativeColor | string | "danger" | colour of values below zero in `bar` and `winloss` |
fill | boolean | — | line only: shade the area under the line |
dot | boolean | — | line only: a dot on the last value |
label | string | — | what is plotted; read with the summary by screen readers |
format | ((v: number) => string) | — | text for one value in the summary, e.g. `(v) => v + " ms"` |
min | number | — | the bottom and the top of the scale, to put several sparklines on one scale |
max | number | — |