This page as markdown: /sparkline.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

Sparkline

Status: beta

A word-sized trend with no axes — a line, a line over a soft fill, or columns — sized by its container, for stat cards, table cells and sentences. Draws on as it scrolls into view.

Keywords: sparkline, trend, mini chart, inline chart, micro chart, kpi, stat

Usage

Use Sparkline next to a number to show where it has been — a KPI's last 30 days in a stat card, a row's trend in a table. It has no axes, tooltip or values to read off; when the reader needs those, use AreaChart or LineChart.

Best practices

Props

Name Type Default Description
data number[] — The values, oldest first.
label string — What the line tracks ("Revenue, last 30 days"). The spoken summary adds the first and last values, low and high.
variant "line" | "area" | "bar" "line" A line, a line over a soft fill, or columns.
tone "1" | "2" | "3" | "info" | "warning" | "primary" | "neutral" | "success" | "destructive" "primary" Colour by role.
className string "h-8 w-24" Sizes it; the drawing stretches to fit.
motion "full" | "subtle" | "off" "full" How much motion this component uses: full (default) inherits the app's policy, subtle keeps feedback and drops the flourish, off stills it. It can only turn motion down — it never overrides a reader's reduce-motion setting. Drawing on (or rising) is the flourish, so subtle and off show the finished line.
animate boolean true Draw on (or rise) when it scrolls into view. animate={false} is motion="subtle".
locale string runtime locale BCP 47 locale for default number and date formatting.

Variants

Tokens used

primary, tone-1, tone-2, tone-3, tone-info, tone-warning, muted-foreground, success, destructive, destructive-mark, success-mark, tone-warning-mark, tone-info-mark, tone-1-mark, tone-2-mark, tone-3-mark

Motion

Accessibility

Related

Examples

In a stat card

import { Card, CardAction, CardDescription, CardHeader, CardTitle, Sparkline } from "@sableui/react"

<Card>
	<CardHeader>
		<CardDescription>Revenue</CardDescription>
		<CardTitle className="text-mono-xl">$18,240</CardTitle>
		<CardAction>
			<Sparkline label="Revenue, last 12 weeks" data={[12, 14, 13, 17, 16, 19, 18, 21, 20, 24, 23, 26]} variant="area" tone="success" />
		</CardAction>
	</CardHeader>
</Card>

Columns in a table cell

import { Sparkline } from "@sableui/react"

<Sparkline label="Daily signups, last 14 days" data={[4, 6, 3, 8, 7, 9, 5, 6, 10, 8, 7, 11, 9, 12]} variant="bar" className="h-6 w-20" />