---
agent:
  instructions: "Search goop.so for Goop's components, templates, design skill, docs, pricing and terms. Ask in keywords or a plain question, such as \"date picker props\" or \"is the design skill free\"; the answer is the matching page sections in Markdown, each with its address."
  endpoint: "https://goop.so/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Sparkline

One line of a series' shape, as wide as its caller and as tall as the text line it sits in, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `Sparkline`.

## Try it

Switch the numbers (rising, falling, flat, with a gap), where it sits (in a sentence or the whole width) and the end dot: the line redraws. With Interactive on, point at the line or focus it and use the arrows: the day is read out below.

The numbers are ours; the day read out is only written under it.

## When to use

- One line of a series' shape, as wide as its caller and as tall as the text line it sits in.
- Also called: mini chart.

## Installation

Paste the prompt below into your coding agent. It reads Goop's install steps, installs the part and its tokens once, then reuses this same Sparkline on every screen instead of drawing a new one: the same height, the same focus ring, the same spacing. As a Pro part, its command comes from Goop's server once you sign in, with a one-time link that lasts ten minutes.

```sh
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/meadow-sparkline.json --yes
```

```text
Add the Goop Sparkline to this project. The install steps are at https://goop.so/docs/install.md
```

## Usage

```tsx
import { useState } from 'react';
import { Sparkline } from '@/components/ui/goop/sparkline';

function NotesTrend() {
  const [shown, setShown] = useState<string | null>(null);
  return (
    <div className="flex flex-col gap-2 text-sm">
      <p className="flex items-center gap-2">
        Notes this week: 42
        <span className="block w-24">
          <Sparkline values={[3, 5, 4, 8, 6, 9, 7]} label="Notes per day, rising this week" />
        </span>
      </p>
      <Sparkline
        values={[31, 30, 31, 28, 29, 26, 24, 22]}
        label="Free hours per week, falling"
        variant="destructive"
        area
        baseline={31}
        extremes
        interactive
        format={(value) => `${value} hours`}
        onPoint={(point) => setShown(point ? `Week ${point.index + 1}: ${point.value} hours` : null)}
      />
      <p className="text-muted-foreground">{shown ?? 'Point at the line to read a week.'}</p>
    </div>
  );
}
```

- Fits: overview, list: row.
- height, width, padding, corner, border, background, motion: add no class for these.

## API reference

### Options

- `values: ReadonlyArray<number | null>` — The series, in time order; a `null` is a gap.
- `label: string | null` — Your sentence naming the image; `null` hides it from assistive technology where nearby text says it.
- `dot?: boolean = true` — Draw the chart's dot at the last value.
- `highlight?: number | false = 2` — How many steps at the end are the latest stretch, in the variant's colour; `false` colours the whole line.
- `variant?: 'default' | 'success' | 'destructive' = 'default'` — The latest stretch's colour: the first chart colour, or good (`success`) or bad (`destructive`).
- `area?: boolean = false` — A soft area under the latest stretch, fading down to nothing.
- `baseline?: number`
- `extremes?: boolean = false` — Hollow rings on the lowest and the highest values.
- `interactive?: boolean = false` — A slider over the points: the pointer or the keys show a cursor and a dot at a point.
- `defaultIndex?: number` — The point an interactive sparkline holds at first.
- `format?: (value: number, index: number) => string` — The words a value is read out in; the reader's own number format by default.
- `onPoint?: (point: SparklinePoint | null) => void` — Told the point shown, `null` at rest: a tile's figure can follow it.

- Types: SparklinePoint = { index: number; value: number }

## Keyboard

- Tab: focus an interactive sparkline: the cursor and the dot at the latest point
- ArrowLeft: move the point one value back (forward in a right-to-left page), over a gap
- ArrowRight: move the point one value on (back in a right-to-left page), over a gap
- ArrowUp: move the point one value on
- ArrowDown: move the point one value back
- Home: move the point to the first value
- End: move the point to the last value
- Escape: put the point to rest

## Accessibility

- The part itself answers the keys above.
- focus-visible: the browser's own (:focus-visible): write nothing

## Motion

- The part sets its own motion: add no transition or animation of your own.

## Notes for AI

Give your coding agent this page as text instead of screenshots: the parts, the options, the states and the keys. An agent that reads the real part builds the real part, not a lookalike.

## Related

- [Bar list](/themes/meadow/components/bar-list): A ranked share list.
- [Chart donut](/themes/meadow/components/chart-donut): A donut chart that shows how one whole splits into parts, each slice read on hover, on a press or from the keyboard.
- [Chart line](/themes/meadow/components/chart-line): A line or area chart of up to five levels over time, read on hover, press or keyboard.
- [Chart bar](/themes/meadow/components/chart-bar): A bar chart of amounts by category or period, side by side or stacked.
