Theme studio

Design a theme, preview it live, then export it. Saved in this browser.

Quick picks #10b981
Generated scale
50100200300400500600700800900
Some text is below AA

Sparkline

  • Stable
  • WCAG 2.2 evidence
  • RTL

A tiny inline trend graphic for a slot like the sparkline of MetricCard: a line over the data, the area under it at 12 % and a dot at the end. Data driven: data in, SVG out. Presentational: no hooks and no "use client", so it renders in React Server Components from props; it has no tooltip, no focus and no motion. Accessibility: the SVG is an image (role="img") that needs a text alternative (aria-label or aria-labelledby), because a sparkline has no axes and no values to read; or decorative (aria-hidden) when the text beside it already says the same (WCAG 1.1.1, 1.4.1). Direction is never colour alone: the shape of the line shows it, the end marker shows where it ends, and the colour only tones it (brand for rising and volatile, danger for falling). The line is at least 3:1 against the card (1.4.11). The time axis stays left-to-right in right-to-left pages (1.3.2). Consumer duties: write the label with the direction and the range ("Payroll over the last 12 months, rising 8 percent"); for exact values or axes use a LineChart.

import { Sparkline } from "@nexera-ui/react";
Loading example…
12
examples
10
props
4
live controls
1
platform
4
WCAG criteria
2
blocks use it

Try every prop. Copy the code.

Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.

Loading…
decorative
trend
smooth
area
Generated code
import { Sparkline } from "@nexera-ui/react";

<Sparkline />

Examples 11

The same examples as Storybook, rendered live. Open Code to copy one.

Falling

Trend=Falling: the line and the dot turn status/danger/solid. The trend comes from the data when you do not pass one.

Loading example…

Volatile

Trend=Volatile: the line moves up and down and ends where it began.

Loading example…

Flat

flat is not in Figma: the neutral grey of the chart palette, for data that hardly moves.

Loading example…

Smooth without area

A smooth monotone curve, without the area.

Loading example…

Missing values

Gaps (null) break the line and the area.

Loading example…

Single and empty

One value is a point; no value is a dashed line. The label should still say what is missing.

Loading example…

Many points

365 daily points: the line stays one path; the label carries what matters.

Loading example…

Fills container

The size is yours: width and height set the drawing; className="w-full h-auto" fits it to its container and keeps the proportions.

Loading example…

Decorative

Next to text that already says it all, the sparkline is decorative and hidden from assistive technology.

Loading example…

In metric card

In the sparkline slot of a MetricCard, 90 x 36 px as in the Figma card.

Loading example…

Right to left

Right-to-left page: the time axis keeps its left-to-right direction; the label is in the page language.

Loading example…

Props 10

Press "Try it" on a card to load that prop into the playground.

10 props shown

aria-labelNexera
string

What the sparkline shows, in words: "Payroll over the last 12 months, rising 8 percent". Say the direction and the range, because the graphic has no axes. Translate it. Text alternative used when aria-labelledby is not set.

Default –
aria-labelledbyNexera
string

Id of an element that names the sparkline; wins over aria-label. Id of the visible element that says what the sparkline shows (the metric label and its caption).

Default –
decorativeNexera
boolean

Not decorative: it is a named image. The text next to the sparkline already says everything it shows (a delta badge "+8 %" and a caption "last 12 months"): hide the drawing from assistive technology (aria-hidden). Only then is aria-label not needed.

Default –
data*Nexera
readonly (number | null)[]

The values in time order, oldest first. null is a gap: the line and the area break there. One value is drawn as a point, no value as a dashed line.

Default –
trendNexera
"rising" | "falling" | "volatile" | "flat"

The direction of the data and the tone of the graphic. The line itself shows the direction by its shape and the end marker shows where it ends, so the colour is never the only cue (WCAG 1.4.1); say it in words in aria-label.

Default derived from `data`: rising or falling when the last value is well above or below the first, volatile when it moves up and down and ends near where it began, flat when it hardly moves
widthNexera
number

Width of the drawing in px. The SVG keeps its proportions when CSS resizes it, so className="w-full h-auto" fits it to a container.

Default 120
heightNexera
number

Height of the drawing in px.

Default 36
smoothNexera
boolean

Draw a smooth monotone curve instead of straight segments; the curve never leaves the data range.

Default false
areaNexera
boolean

Fill the area between the line and the bottom edge.

Default true
classNameNexera
string

Extra classes, merged last so they win over the defaults.

Default –

* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.

Accessible by default.

Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.

WCAG 2.2 evidence

3 direct · 1 supporting
  • 1.1.1Non-text ContentLevel A · tested directly
  • 1.3.2Meaningful SequenceLevel A · supporting test
  • 1.4.1Use of ColorLevel A · tested directly
  • 4.1.2Name, Role, ValueLevel A · tested directly

Fits any width.

Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.

0 px · drag the corner

Styling hooks

Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.

Usage
<Sparkline className="shadow-sm" />

Used in blocks

Related components