Skip to main content

Sparkline

Every example on this page is live, drawn by the library's Storybook, where you can also change its props and see the result.

A compact inline line chart with no axes, ideal for showing trends in small spaces. The trace stretches to fill its box, from the lowest value at the bottom to the highest at the top, while its stroke and dot keep their size. A series that never changes is drawn as a level line through the middle.

Import​

import { Sparkline } from "~lib/charts/sparkline";

Props​

NameTypeRequiredDefaultDescription
datanumber[]YesN/AData values (min 2 points)
widthnumber | stringNo100Chart width in px or CSS length
heightnumber | stringNo30Chart height in px or CSS length
showDotbooleanNofalseShow dot on the last point
smoothbooleanNofalseUse smooth curves instead of lines

Examples​

Simple​

Open Simple in Storybook

With End Dot​

Open With Dot in Storybook

Large Size​

Open Large Size in Storybook

Flat Line​

Open Flat Line in Storybook

See Also​