---
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/"
---

# Chart bar

A bar chart of amounts by category or period, side by side or stacked, for React and Tailwind CSS. Part of Goop Pro.

Pro. Its export: `ChartBar`.

## Try it

Point at a bar (or Tab to the plot and use the arrows) and the headline follows it; switch grouped or stacked, the average line, the readout, the look (one series, two grouped, a change below zero), the legend beside, loading.

The numbers are ours.

## When to use

- A bar chart of amounts by category or period, side by side or stacked.
- Also called: bar graph.

## When not to use

- A flow in and out over time is stacked, the outflow negative.

## 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 bar 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-chart-bar.json --yes
```

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

## Usage

```tsx
import { ChartBar } from '@/components/ui/goop/chart-bar';

function VisitsThisWeek() {
  return (
    <ChartBar
      title="Site visits"
      description="This week, by day"
      summary="Site visits each day this week: Tuesday had the most."
      config={{ visits: { label: 'Visits' } }}
      categoryKey="day"
      unit="visits"
      readout={{ label: 'Daily average', value: 'average', detail: 'against last week', change: 0.08 }}
      data={[
        { day: 'Mon', visits: 12 },
        { day: 'Tue', visits: 19 },
        { day: 'Wed', visits: 15 },
        { day: 'Thu', visits: 17 },
        { day: 'Fri', visits: 9 },
      ]}
    />
  );
}
```

- height, width, gap, background, text, motion: add no class for these.

## API reference

### Options

- `variant: default | stacked = default`
- `config: NoInfer<ChartConfig<ChartKey<Data>>>` — The series, in order, each keyed by a field of the rows: its `label`, and `dashed` if 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.
- `average?: boolean` — The dashed average line, its value in the end gutter: on by default with a `readout`.
- `averageLabel?: string = 'Avg'` — The word before the average's value.
- `Defaults: encode = true; otherLabel = 'Other'`

- Takes every prop of ChartContainer but plot, children, scrub, toggles and stack (its page: chart.md)

## Keyboard

- 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 part itself answers the keys above.

## 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

- [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 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.
- [Sparkline](/themes/meadow/components/sparkline): One line of a series' shape, as wide as its caller and as tall as the text line it sits in.
- [Bar list](/themes/meadow/components/bar-list): A ranked share list.
