npx shadcn@4.23.1 add https://registry.goop.so/g/<link>/trail-chart.json --yesChart container
ProThe card a custom chart is drawn in, with its grid, axes, series markers, tooltip and legend, for React and Tailwind CSS. Part of Goop Pro.
What an agent sees
- ChartFitTextChart text cut with an ellipsis to fit the width in max
- ChartDotA point's marker in its series' shape and colour
- ChartSeriesMarkerA series' marker standing alone, in the dot's box
- ChartSeriesStrokeA series' line standing alone, a cell long in the dot's height
- ChartAxisTickOne axis label
- ChartGridFaint lines at each value tick
- ChartCursorThe line at the active point
- ChartSeriesLabelA series' direct label at its line's end, in the gutter the plot keeps for it, shortened to fit
- ChartAxesBoth axes, categories below and values at the side
- ChartLinesOne line per series through the rows you pass it
- ChartTooltipContentThe tooltip's words at the active point
- ChartTooltipThe panel of each series' value at the active point
- ChartLegendContentThe legend's entries
- ChartLegendThe legend under the plot, from the second series (one series needs none: the title names it)
- ChartTableThe data as a table, always in the page and hidden from sight
- ChartHeaderThe chart card's header
- ChartEmptyThe plot's empty state
- ChartLoadingThe plot while its data loads
- ChartErrorThe plot when it cannot draw
import {
ChartFitText, ChartDot, ChartSeriesMarker, ChartSeriesStroke, ChartAxisTick, ChartGrid, ChartCursor, ChartSeriesLabel, ChartAxes, ChartLines, ChartTooltipContent, ChartTooltip, ChartLegendContent,
ChartLegend, ChartTable, ChartHeader, ChartEmpty, ChartLoading, ChartError, ChartContainer,
} from '@/components/ui/goop/chart';
<ChartContainer
title="Notes written"
description="This week, by day"
summary="Notes written each day this week: Wednesday is the busiest."
config={{ notes: { label: 'Notes' } }}
categoryKey="day"
data={[
{ day: 'Mon', notes: 4 },
{ day: 'Tue', notes: 6 },
{ day: 'Wed', notes: 9 },
{ day: 'Thu', notes: 5 },
{ day: 'Fri', notes: 3 },
]}
/>Point at the plot (or Tab to it and use the arrows) to read a day, and hide a series by its legend entry: the line under it says which; switch one to three series, the readout headline, the day held as the chart opens, the labels and markers, stacking (the held day’s readout sums the series), the legend beside, its toggles, whole ticks, loading, an error with Retry, and the unit. The hours are ours; Retry only counts; the day read and the series hidden are only written under it.
When to use
- The card a custom chart is drawn in, with its grid, axes, series markers, tooltip and legend.
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 Chart container 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-chart.json --yesAdd the Goop Chart container to this project. The install steps are at https://goop.so/docs/install.mdUsage
import {
ChartFitText, ChartDot, ChartSeriesMarker, ChartSeriesStroke, ChartAxisTick, ChartGrid, ChartCursor, ChartSeriesLabel, ChartAxes, ChartLines, ChartTooltipContent, ChartTooltip, ChartLegendContent,
ChartLegend, ChartTable, ChartHeader, ChartEmpty, ChartLoading, ChartError, ChartContainer,
} from '@/components/ui/goop/chart';
<ChartContainer
title="Notes written"
description="This week, by day"
summary="Notes written each day this week: Wednesday is the busiest."
config={{ notes: { label: 'Notes' } }}
categoryKey="day"
data={[
{ day: 'Mon', notes: 4 },
{ day: 'Tue', notes: 6 },
{ day: 'Wed', notes: 9 },
{ day: 'Thu', notes: 5 },
{ day: 'Fri', notes: 3 },
]}
/>- Fits: overview: body.
- Also known as: Chart.
- The plot is 16:9 of the chart's width up to 352 px tall; a chart across a whole page keeps that height and grows only wider, so a chart of a few marks reads best in a column or a CardGrid cell beside another panel, not alone across a wide page.
- height, width, padding, gap, corner, background, text, motion: add no class for these.
API reference
- Each option with its sentence: chart--options.md
- State: hiddenSeries (hiddenSeries / defaultHiddenSeries / onHiddenSeriesChange)
| Part | What it is |
|---|---|
| ChartFitText | Chart text cut with an ellipsis to fit the width in max |
| ChartDot | A point's marker in its series' shape and colour |
| ChartSeriesMarker | A series' marker standing alone, in the dot's box |
| ChartSeriesStroke | A series' line standing alone, a cell long in the dot's height |
| ChartAxisTick | One axis label; ChartAxes draws these for you |
| ChartGrid | Faint lines at each value tick; put it first in ChartContainer's children |
| ChartCursor | The line at the active point; ChartTooltip draws it |
| ChartSeriesLabel | A series' direct label at its line's end, in the gutter the plot keeps for it, shortened to fit |
| ChartAxes | Both axes, categories below and values at the side |
| ChartLines | One line per series through the rows you pass it |
| ChartTooltipContent | The tooltip's words at the active point |
| ChartTooltip | The panel of each series' value at the active point |
| ChartLegendContent | The legend's entries; with toggles each shows or hides its series |
| ChartLegend | The legend under the plot, from the second series (one series needs none: the title names it) |
| ChartTable | The data as a table, always in the page and hidden from sight |
| ChartHeader | The chart card's header |
| ChartEmpty | The plot's empty state |
| ChartLoading | The plot while its data loads |
| ChartError | The plot when it cannot draw |
ChartAxes
Both axes, categories below and values at the side.
import { ChartAxes } from '@/components/ui/goop/chart';Options
- valuePadding?: { top?: number; bottom?: number } — Room kept at the value axis's ends, px.
- band?: boolean — A band axis — bars: every category sits in the middle of its band.
ChartAxisTick
One axis label; ChartAxes draws these for you.
import { ChartAxisTick } from '@/components/ui/goop/chart';Options
- x?: number = 0 — The tick's place across, px (the library's).
- y?: number = 0 — The tick's place down, px (the library's).
- payload?: { value: unknown } — The tick's value: a category, or a number.
- index?: number = 0 — The tick's place among the axis's ticks, from 0.
- visibleTicksCount?: number — How many ticks the axis draws (the library's; not read).
- width?: number — The axis's length, px (the library's; not read).
- orientation?: string — The axis's side: a number on a value axis at the right starts at its tick.
- band?: boolean — A band axis — bars: the library sets every category in the middle of its band (not read: every word is centred).
- shown?: ReadonlySet<number> | null — The categories the axis writes, by their place from 0; all when left out.
ChartCursor
The line at the active point; ChartTooltip draws it.
import { ChartCursor } from '@/components/ui/goop/chart';Options
- points?: ReadonlyArray<{ x: number; y: number }> — The line's two ends, px (the library's, at the active point).
ChartDot
A point's marker in its series' shape and colour.
import { ChartDot } from '@/components/ui/goop/chart';Options
- series: number — The series' place in the config, from 0: its colour and its shape.
- cx: number — The point's centre across, px.
- cy: number — The point's centre down, px.
ChartEmpty
The plot's empty state.
import { ChartEmpty } from '@/components/ui/goop/chart';Options
- children?: ReactNode = 'No data to show.' — The empty state's words.
ChartError
The plot when it cannot draw.
import { ChartError } from '@/components/ui/goop/chart';Options
- children: ReactNode — The error's sentence.
- onRetry?: () => void — Called by the retry button; none is drawn without it.
- retryLabel?: string = 'Retry' — The retry button's words.
ChartFitText
Chart text cut with an ellipsis to fit the width in max.
import { ChartFitText } from '@/components/ui/goop/chart';Options
- text: string — The words; drawn whole when they fit.
- max: number — The widest the words may be drawn, px.
ChartGrid
Faint lines at each value tick; put it first in ChartContainer's children.
import { ChartGrid } from '@/components/ui/goop/chart';Options
ChartHeader
The chart card's header.
import { ChartHeader } from '@/components/ui/goop/chart';Options
- title: string — The chart's title.
- description?: string — A line under the title.
- action?: ReactNode — The range control at the header's end.
- titleId?: string — The title's id, which names the chart.
ChartLegendContent
The legend's entries; with toggles each shows or hides its series.
import { ChartLegendContent } from '@/components/ui/goop/chart';Options
- toggles?: boolean = false — Each entry hides or shows its series.
- strokes?: boolean = false — Each series as a short length of its line, rather than its marker.
ChartLegend
The legend under the plot, from the second series (one series needs none: the title names it).
import { ChartLegend } from '@/components/ui/goop/chart';Options
- toggles?: boolean = false — Each entry hides or shows its series.
- strokes?: boolean = false — Each series stands as a short length of its line rather than its marker.
ChartLines
One line per series through the rows you pass it.
import { ChartLines } from '@/components/ui/goop/chart';Options
- data: readonly object[] — The chart's rows, in the category axis's order.
- encode?: boolean = true — The second encoding: the direct labels and a dash from the third series.
- markers?: boolean — Every point in its series' marker (
true), or none ever (false). - labels?: boolean = true — The direct labels at the lines' ends; off where a legend of the lines' strokes names them.
ChartLoading
The plot while its data loads.
import { ChartLoading } from '@/components/ui/goop/chart';Options
ChartContainer: every option
import { ChartContainer } from '@/components/ui/goop/chart';Options
- title: string — The chart's title, in its header; it names the chart.
- description?: string — A line under the title.
- summary: string — What the chart shows, in one sentence: its description for a person who cannot see it (required).
- action?: ReactNode — The range control at the header's end, none by default: segmented Tabs whose triggers name
panelIdwitharia-controls, or a Select. - panelId?: string — The id of the chart's body as the ONE panel a tab strip in the header switches.
- config: NoInfer<ChartConfig<ChartKey<Data>>> — The series, in order, each keyed by a field of the rows: its
label, anddashedif wanted. - data: Data — The rows, in the category axis's order: of the caller's own type (an interface too) or
ChartRow. - categoryKey: NoInfer<ChartKey<Data>> — The field of each row that holds its category.
- encode?: boolean = true — The second encoding, on by default: a direct label at each line's end, a dash from the third series.
- markers?: boolean — Every point in its series' marker (
true), or none ever (false). - locale?: string — The numbers' locale; the document's language by default.
- format?: Intl.NumberFormatOptions — The numbers'
Intl.NumberFormatoptions. - unit?: string — The words after a full value (the tooltip, the table); in the readout, set small after the number.
- loading?: boolean = false — The data is loading: one skeleton block fills the plot's box where the marks will be.
- error?: string — Why the chart cannot draw: the error state says it.
- onRetry?: () => void — The error state's retry.
- defaultIndex?: number — The point whose tooltip shows when the chart mounts (a preview, a held picture).
- readout?: ChartReadout — The readout layout: the headline in the card under the title, at rest this, following the active item.
- plot?: ChartPlot — The chart library's chart element the ready plot is drawn with: its line chart by default.
- children?: ReactNode — What is drawn in the ready plot: by default the grid, the axes, the tooltip and the line layer.
- endLabels?: boolean | 'always' — Whether the plot keeps a gutter for direct labels at its end edge: by default when no
childrenare given and two series or more are drawn. - legend?: ReactNode — What stands where the legend stands, in the ready state alone: by default the series' legend, from the second.
- scrub?: boolean — The plot is a slider over its categories: arrows, PageUp and PageDown (seven), Home and End move the active point, Escape puts it to rest.
- toggles?: boolean — The default legend's entries hide and show their series: by default, when no
childrenare given. - stack?: boolean = false — The series stack: an active item's number in the readout is their sum.
- legendBeside?: boolean = false — Sets the legend beside the plot where the card's body is 36rem wide or more, under it when narrower; off by default.
- wholeNumbers?: boolean — The value axis writes whole numbers alone, never 0.75 or 2.5: by default when every value of every series is whole.
- otherLabel?: string = 'Other' — The label of the series that holds the rest where more than five are given: the four with the largest totals are drawn as given and the others summed into this one, drawn last, its legend entry naming them.
- hiddenSeries?: readonly string[] — The hidden series' keys, held by the caller.
- defaultHiddenSeries?: readonly string[] — The series hidden at first.
- onHiddenSeriesChange?: (hidden: string[]) => void — Called with the hidden keys as a toggle changes them.
- onActiveIndexChange?: (index: number | null) => void — Called with the active row's index,
nullat rest. - State: hiddenSeries (hiddenSeries / defaultHiddenSeries / onHiddenSeriesChange)
- Types: ChartReadout = { label: string; value: number | 'total' | 'average'; detail?: string; change?: number; measure?: string; compare?: string }
ChartSeriesLabel
A series' direct label at its line's end, in the gutter the plot keeps for it, shortened to fit.
import { ChartSeriesLabel } from '@/components/ui/goop/chart';Options
- x: number — The line's last point across, px.
- y: number — The line's last point down, px.
- children: string — The series' label.
ChartSeriesMarker
A series' marker standing alone, in the dot's box.
import { ChartSeriesMarker } from '@/components/ui/goop/chart';Options
- series: number — The series' place in the config, from 0: its colour and its shape.
ChartSeriesStroke
A series' line standing alone, a cell long in the dot's height.
import { ChartSeriesStroke } from '@/components/ui/goop/chart';Options
- series: number — The series' place in the config, from 0: its colour and its dash.
ChartTable
The data as a table, always in the page and hidden from sight.
import { ChartTable } from '@/components/ui/goop/chart';Options
- data: readonly object[] — The chart's rows.
- title: string — The chart's title, which names the table.
ChartTooltipContent
The tooltip's words at the active point.
import { ChartTooltipContent } from '@/components/ui/goop/chart';Options
- label?: unknown — The active point's category (the library's).
- payload?: ReadonlyArray<{ payload?: ChartRow }> — The active point's entries (the library's): the row they are of is read.
- strokes?: boolean = false — Each series keyed by a short length of its line, rather than its marker.
ChartTooltip
The panel of each series' value at the active point.
import { ChartTooltip } from '@/components/ui/goop/chart';Options
- defaultIndex?: number — The point whose tooltip shows when the chart mounts.
- offset?: number — How far the panel stands from the active point, px (10 by default).
- cursor?: ReactElement — The cursor at the active point: by default the line down the plot.
- panel?: boolean = true — Whether the panel is drawn.
- strokes?: boolean = false — The panel keys each series by its stroke, as a legend of strokes does.
Keyboard
| Key | What it does |
|---|---|
| Tab | Focus the plot |
| ArrowLeft | Move the active point one category |
| ArrowRight | Move the active point one category |
| ArrowUp | Move the active point to the next category |
| ArrowDown | Move the active point to the previous category |
| PageUp | Move the active point seven categories on |
| PageDown | Move the active point seven categories back |
| Home | Move the active point to the first category |
| End | Move the active point to the last category |
| Escape | Put the active point to rest |
Accessibility
- The native element answers the keyboard.
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.