Skip to content
GeneralGenerated from the public API

Sparkline

Compare series and read the change behind them, with the axes, legend and tooltip already wired.

@luc/ui/charts

What it shows

Give a compact visual cue for the shape or direction of a short numeric series inside a card or table cell.

Live preview

Eight readings, no axes and no labels — a sparkline is a shape, not a chart you read values off.

Sharpe1.24
<Sparkline
  values={[0.9, 1.05, 1.02, 1.18, 1.1, 1.22, 1.31, 1.24]}
  tone="positive"
  marker
  width={160}
  height={40}
  ariaLabel="Sharpe ratio"
/>

Controls

Modified

Height

200px

A chart measures its container, so it always needs a definite height.

State

The surface the chart is in — loading, empty and error are drawn by the component.

Accessible name

A drawing is not readable by a screen reader, so it needs a name that states what it shows.

The same fixture as the live preview above; the controls change how it is drawn, not what it measures.

Code
import { Sparkline } from "@luc/ui/charts";

<Sparkline
  values={[0.9, 1.05, 1.02, 1.18, 1.1, 1.22, 1.31, 1.24]}
  tone="positive"
  marker
  width={160}
  height={200}
  ariaLabel="Sharpe ratio"
  state="ready"
/>

Not controllable here

  • series / rows — The numbers are the caller's; the fixture above is the example.
Copy for an AI agentA specification an agent can act on: the import, the setup, the chosen props, the data contract and the accessibility expectation.
Implement `Sparkline` from Luc UI. It is: Compare series and read the change behind them, with the axes, legend and tooltip already wired.

Import it with: import { Sparkline } from "@luc/ui/charts";
Requires: react ^19.0.0; react-dom ^19.0.0; react-hook-form ^7.0.0 (optional, for @luc/ui/forms/react-hook-form); tailwindcss ^4.0.0; node >= 22 (repository tools). Import the stylesheet once at the app root and wrap the tree in `LucProvider`. Both come from the package that publishes @luc.

Chosen configuration: `height={200}`, `state="ready"`, `ariaLabel="Sharpe ratio"`.

Accessibility: keep the component's own semantics. Do not re-implement its ARIA wiring, do not add roles it does not declare, and make sure every interactive element is reachable and operable from the keyboard with a visible focus state.
Styling: use Luc UI design tokens and the component's own props. Do not restyle with raw colour literals and do not override the component's internal structure with page CSS.
Motion: respect `prefers-reduced-motion`. The component already does, so do not disable it.

Reproduce this state:
```tsx
<Sparkline
  values={[0.9, 1.05, 1.02, 1.18, 1.1, 1.22, 1.31, 1.24]}
  tone="positive"
  marker
  width={160}
  height={200}
  ariaLabel="Sharpe ratio"
  state="ready"
/>
```

Usage

The values are prepared by the caller: this component draws the points it is given and computes no statistic of its own, so units, scaling and any summary have to be settled before the data reaches it.

It is drawn by the ECharts engine.

Worked examples with real data are on the family overview: General

import { Sparkline } from "@luc/ui/charts";
<Sparkline
  values={[0.9, 1.05, 1.02, 1.18, 1.1, 1.22, 1.31, 1.24]}
  tone="positive"
  marker
  width={160}
  height={40}
  ariaLabel="Sharpe ratio"
/>

Data contract

`values` is an ordered array of numbers. A sparkline has no x labels, y ticks or chart table; the surrounding text must name the measure and time window.

Important configuration

Choose `tone` for semantic direction, `marker` for the latest point, and an explicit `width`/`height` that fits the host line box.

Guidelines

When not to use

Do not use a sparkline when the reader needs exact values, axis units or a defensible comparison; use a full chart or a number with its unit.

Configuration

Exported symbols
ExportKindSignature
Sparkline10 documented props({ values, tone, autoTone, fill, marker, strokeWidth, width, height, className, ariaLabel, }: SparklineProps) => import("@types/react").JSX.Element

Sparkline props

Type: SparklineProps

Values the compiler reads from the declaration.

Sparkline props
PropTypeDefaultNotes
ariaLabel?string | undefined—
autoTone?boolean | undefined—Derive the tone from the first/last values — the dashboard convention.
className?string | undefined—
fill?boolean | undefined—
height?number | undefined—
marker?boolean | undefined—
strokeWidth?number | undefined—
tone?SparkTone | undefined—
valuesreadonly (number | null)[]—
width?number | undefined—

Accessibility

A chart is a picture of data, so it needs a name that states what it shows, and the numbers must exist as text somewhere on the page — in a table or a written summary — because a drawing is not readable by a screen reader and cannot be copied.

What happens on the server, and when hydration changes it.

Luc UI v1.0Sparklinedark theme