npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-sparkline.json --yesSparkline
ProOne 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.
What an agent sees
import { Sparkline } from '@/components/ui/goop/sparkline';
<>
<p>
Notes this month: 42 <Sparkline values={[3, 5, 4, 8, 6, 9, 7]} label="Notes per day, rising this week" />
</p>
<Sparkline
values={[31, 30, 31, 28, 29, 26, 24, 22]}
label="Weekly retention, falling"
variant="destructive"
area
baseline={31}
extremes
interactive
format={(value) => `${value}%`}
/>
</>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.
npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-sparkline.json --yesAdd the Goop Sparkline to this project. The install steps are at https://goop.so/docs/install.mdUsage
import { Sparkline } from '@/components/ui/goop/sparkline';
<>
<p>
Notes this month: 42 <Sparkline values={[3, 5, 4, 8, 6, 9, 7]} label="Notes per day, rising this week" />
</p>
<Sparkline
values={[31, 30, 31, 28, 29, 26, 24, 22]}
label="Weekly retention, falling"
variant="destructive"
area
baseline={31}
extremes
interactive
format={(value) => `${value}%`}
/>
</>- Fits: overview (its recipe); overview, list: row.
- height, width, padding, corner, border, background, motion: add no class for these.
API reference
| Option | Type | What it does |
|---|---|---|
| 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 theme'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? | Extract<StatusVariant, 'default' | 'success' | 'destructive'> = 'default' | The latest stretch's colour: the first data 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 | Small hollow marks on the lowest and the highest values. |
| interactive? | boolean = false | A slider over the points: the pointer or the keys show a hairline 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 }
- data-slot values (to select a part by): sparkline, sparkline-active, sparkline-area, sparkline-baseline, sparkline-cursor, sparkline-dot, sparkline-extreme, sparkline-highlight, sparkline-line, sparkline-plot
Keyboard
| Key | What it does |
|---|---|
| Tab | Focus an interactive sparkline: the hairline 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.
- How the theme moves, and how to move your own parts the same way: Motion.
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.