Skip to content
THE COMPONENT LIBRARY
Skip to content

Component reference

Sparkline

Add a compact, accessible trend to a metric or table cell.

Preview

Live preview

Changes apply to this preview only.

Loading the interactive example?

Width adapts to the available space

More examples

Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.

Filled trend

Add subtle area emphasis to a compact metric.

Open preview

A falling metric

A downward trend can be desirable, for example for latency.

Open preview

Stable values

Represent a constant series without inventing variation.

Open preview

Named-part customization

Style this chart directly through typed geometry and surface hooks.

Open preview

Usage

Provide data in chronological order. area fills below the trend, and color accepts an explicit stroke color. Use a full chart when readers need axes or interactive exploration.

Use valueFormatter for readable units. These charts do not implement zoom, pan or time-axis aggregation. Demo data is fictional.

API reference

Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.

PimoluSparklineProps

Type source
PimoluSparklineProps public API
NameTypeDefaultDescription
classNamesPimoluClassNames<"chart"> | undefined—Additive classes for stable named parts, including composed descendants. Parts: area, axis, axisLabel, axisTitle, bar, canvas, centerLabel, centerValue, cursor, donutTrack, empty, grid, legend, legendItem, legendLabel, legendSwatch, legendValue, line, point, root, segment, srOnly, svg, tooltip, tooltipRow, valueLabel. Parts render only when the corresponding component or state is present.
dataRequirednumber[][]Trend values, oldest first.
areaboolean | undefinedfalseFills the area under the line. Defaults to false.
colorstring | undefined—Explicit line colour. Falls back to the primary token.
widthnumber | undefined160viewBox width. Defaults to 160.
heightnumber | undefined40viewBox height. Defaults to 40.
valueFormatter((value: number) => string) | undefined—Formats values in the hidden data table.
emptyLabelstring | undefined—Text announced when there is nothing to draw.
onChangeChangeEventHandler<HTMLDivElement, Element> | undefined—Standard React/HTML attribute.
defaultValuestring | number | readonly string[] | undefined—Standard React/HTML attribute.
classNamestring | undefined—Standard React/HTML attribute.
styleCSSProperties | undefined—Standard React/HTML attribute.
aria-labelstring | undefined—Defines a string value that labels the current element.
onClickMouseEventHandler<HTMLDivElement> | undefined—Standard React/HTML attribute.
classNames

PimoluClassNames<"chart"> | undefined

No default extracted.

Additive classes for stable named parts, including composed descendants. Parts: area, axis, axisLabel, axisTitle, bar, canvas, centerLabel, centerValue, cursor, donutTrack, empty, grid, legend, legendItem, legendLabel, legendSwatch, legendValue, line, point, root, segment, srOnly, svg, tooltip, tooltipRow, valueLabel. Parts render only when the corresponding component or state is present.

dataRequired

number[]

Default: []

Trend values, oldest first.

area

boolean | undefined

Default: false

Fills the area under the line. Defaults to false.

color

string | undefined

No default extracted.

Explicit line colour. Falls back to the primary token.

width

number | undefined

Default: 160

viewBox width. Defaults to 160.

height

number | undefined

Default: 40

viewBox height. Defaults to 40.

valueFormatter

((value: number) => string) | undefined

No default extracted.

Formats values in the hidden data table.

emptyLabel

string | undefined

No default extracted.

Text announced when there is nothing to draw.

onChange

ChangeEventHandler<HTMLDivElement, Element> | undefined

No default extracted.

Standard React/HTML attribute.

defaultValue

string | number | readonly string[] | undefined

No default extracted.

Standard React/HTML attribute.

className

string | undefined

No default extracted.

Standard React/HTML attribute.

style

CSSProperties | undefined

No default extracted.

Standard React/HTML attribute.

aria-label

string | undefined

No default extracted.

Defines a string value that labels the current element.

onClick

MouseEventHandler<HTMLDivElement> | undefined

No default extracted.

Standard React/HTML attribute.

Accessibility

  • Give the chart a descriptive aria-label including its units. A hidden data table provides the individual observations.
  • Do not rely on color alone.
Read the accessibility guide →