# Bar chart

Compare grouped or stacked values with exact readings, negative values and a data table.

Access: pro. Category: Data. Kind: composite.

## When to use

- Use it when a page needs compare grouped or stacked values with exact readings, negative values and a data table.
- Choose it when the data structure, labels, and state are supplied by the application and must remain consumer controlled.

## Alternatives

- Choose analytics-card instead when explore revenue, compare periods and inspect chart values is the actual interface need, rather than bar chart.

## Setup for agents

Use React 19 and TypeScript. Initialize shadcn for your framework, then merge this exact entry into components.json:

```json
{
  "registries": {
    "@tidal-pro": {
      "url": "https://tidalui.com/r/pro/{name}.json",
      "headers": {
        "Authorization": "Bearer ${TIDALUI_TOKEN}"
      }
    }
  }
}
```

The namespace must be named **@tidal-pro** because transitive Pro dependencies use that namespace. Obtain an agent key from your active Pro account at https://tidalui.com/account. Keep TIDALUI_TOKEN in your local environment, never in components.json, client code, Git or logs.

```sh
export TIDALUI_TOKEN='your-private-agent-key'
npx shadcn@latest add @tidal-pro/waitlist-form
npx shadcn@latest add https://tidalui.com/r/tidal-button.json
```

Free command: `npx shadcn@latest add https://tidalui.com/r/<name>.json`.
Pro command: `npx shadcn@latest add @tidal-pro/<name>`.

Import the base stylesheet and every stylesheet listed on the installed item's metadata. For example:

```tsx
import "./components/ui/tidal.css";
import "./components/ui/hero-section.css";
// Place installed components inside this wrapper:
<div className="tidal-scope" data-theme="dark">...</div>
```

Omit data-theme for the default light theme. Put the attribute on the same tidal-scope element for dark mode. Every component installs the shared free tidal-base dependency. After upgrading, run `npx shadcn@latest add https://tidalui.com/r/tidal-base.json --overwrite` to receive current tokens. Review local modifications before overwriting.

Vite: Use React + TypeScript. Map @/* to ./src/* in paths and Vite resolve.alias. Import tidal.css and each component stylesheet in your application entry.

Next.js 15 App Router: Next.js App Router: import tidal.css and component CSS in app/layout.tsx. Interactive examples belong in a client component with "use client". Map @/* to ./* or ./src/* to match your project.

TypeScript 6: use paths without baseUrl:

```json
{
  "compilerOptions": {
    "paths": {
      "@/*": [
        "./src/*"
      ]
    }
  }
}
```

Pro registry requests are server/CLI-only. Use the same-origin account interface in a browser; cross-origin Authorization preflights are intentionally unsupported.


## Install Bar chart

```sh
npx shadcn@latest add @tidal-pro/bar-chart
```

Stylesheets: `components/ui/tidal.css`, `components/ui/bar-chart.css`.

## Minimal example

```tsx
import"./components/ui/tidal.css";
import"./components/ui/bar-chart.css";
import{TidalBarChart}from"./components/ui/bar-chart";
export default()=><div className="tidal-scope"><TidalBarChart data={[{id:"example",label:"Demo",values:{}}]} series={[{id:"example",label:"Demo"}]} title={"Demo"}/></div>;
```

## Structured props

- `TidalBarChart.data: ReadonlyArray<TidalBarDatum>`: Required data value accepted by this exported component.
- `TidalBarChart.series: ReadonlyArray<TidalBarSeries>`: Required series value accepted by this exported component.
- `TidalBarChart.title: ReactNode`: Required title value accepted by this exported component.
- `TidalBarChart.description?: ReactNode`: Optional description value accepted by this exported component.
- `TidalBarChart.emptyMessage?: ReactNode` (default "No chart data."): Optional empty message value accepted by this exported component.
- `TidalBarChart.formatValue?: ((value: number) => string) | undefined` (default defaultFormat): Optional format value value accepted by this exported component.
- `TidalBarChart.headingLevel?: "h2" | "h3" | "h4" | "h5" | "h6" | undefined` (default "h3"): Optional heading level value accepted by this exported component.
- `TidalBarChart.mode?: "grouped" | "stacked" | undefined` (default "grouped"): Optional mode value accepted by this exported component.

## Complete usage example

[Source](https://tidalui.com/examples/bar-chart.tsx) | [Manifest](https://tidalui.com/examples/bar-chart.json). Install the listed additional dependencies. Consumer fixture: TypeScript pass; Vite pass. This fixture check is distinct from the actual shadcn install receipt.

```tsx
import "./components/ui/tidal.css";

import { TidalBarChart } from "./components/ui/bar-chart";

import "./components/ui/bar-chart.css";



const format = new Intl.NumberFormat("en-US", {
  style: "currency",
  currency: "USD",
  maximumFractionDigits: 0,
});

export function BarChartDemo() {
  return (
    <div style={{ width: "min(100%, 600px)", minWidth: 0 }}>
      <TidalBarChart
        title="Revenue by channel"
        description="Sample monthly revenue. Select a channel to inspect its values."
        series={[
          { id: "current", label: "This month" },
          { id: "previous", label: "Last month" },
        ]}
        data={[
          {
            id: "search",
            label: "Search",
            values: { current: 24800, previous: 19200 },
          },
          {
            id: "direct",
            label: "Direct",
            values: { current: 18600, previous: 15200 },
          },
          {
            id: "referral",
            label: "Referral",
            values: { current: 14200, previous: 16400 },
          },
          {
            id: "social",
            label: "Social",
            values: { current: 8400, previous: 6200 },
          },
        ]}
        formatValue={(v) => format.format(v)}
      />
    </div>
  );
}

export default function AgentExample() {
  return (
    <div className="tidal-scope" data-theme="light" dir="ltr">
      <BarChartDemo />
    </div>
  );
}

```

## Gotchas

- Supply truthful data and labels; the component does not fetch, aggregate, or persist records.

## Theme and accessibility

{"tokens":["--t-accent","--t-border","--t-border-strong","--t-canvas","--t-danger","--t-display","--t-ease-out","--t-ease-spring","--t-faint","--t-font","--t-ink","--t-line","--t-muted","--t-primary","--t-primary-contrast","--t-radius-card","--t-radius-control","--t-radius-overlay","--t-radius-panel","--t-ring","--t-shadow-lg","--t-shadow-soft","--t-soft","--t-subtle","--t-surface","--t-wash"],"darkMode":true}

{"keyboard":["Tab and Shift+Tab follow the component's native focus order.","Arrow-key behavior follows the exported composite-control implementation."],"aria":"The component wires labels and relationships from consumer-provided visible text or ARIA props; preserve those labels in production.","notes":"Verify focus visibility, text alternatives, contrast, and reduced motion in the final composition."}

Data categories and series require stable unique IDs and readable labels. Each category maps series IDs to numeric values; null, undefined and nonfinite values display No data. Optional headingLevel h2 through h6 (default h3), grouped/stacked mode, description, formatValue, emptyMessage and native section attrs/ref. Signed bars share one zero baseline; stacked positive and negative values accumulate separately. Scale normalization keeps finite extreme numbers drawable. Exact formatted values remain beside each row and in a complete semantic table, which opens with the shared Button. Native category buttons inspect the selected record on pointer, focus or activation; their accessible name includes every series value. The default formatter displays at most two fractional digits; provide an appropriate formatter for units and precision. Consumers own data, labels, units and formatting; no fetching or analytics calculation is performed.
