Dashral Pro is on the wayGet 30% off at launch

Dashral

Bar Chart

Values compared across categories or periods as bars: one series, several side by side, or stacked. Plain SVG.

$ pnpm dlx shadcn@latest add https://dashral.com/r/bar-chart.json

Installation

$ pnpm dlx shadcn@latest add https://dashral.com/r/bar-chart.json

Adds the component, the components it builds on, its npm packages and the theme tokens it uses. Using Dashral often? Add the registry to components.json once:

components.json
{
  "registries": {
    "@dashral": "https://dashral.com/r/{name}.json"
  }
}

Then add components by name:

$ pnpm dlx shadcn@latest add @dashral/bar-chart

Usage

example.tsx
import { BarChart } from "@/components/dashral/bar-chart"

<BarChart
  data={[
    { month: "Jan", orders: 120 },
    { month: "Feb", orders: 164 },
    { month: "Mar", orders: 198 },
  ]}
  index="month"
  series={[{ key: "orders", label: "Orders" }]}
  aria-label="Orders by month"
/>

Examples

This year and last

Several series stand side by side; give the comparison a quieter color.

  • 2026
  • 2025

Signups by plan

stacked makes one bar of every series, its height their total; only the top is rounded.

  • Free
  • Pro
  • Team

API reference

BarChart

Also takes every prop of <div>(opens in a new tab).

PropTypeDefault
dataRecord<string, string | number>[]

The rows, in order along the x axis. Required.

—
indexstring

The key for the x axis: a label, or a timestamp or ISO date with timeFormat. Required.

—
series{ key, label, color?, dashed? }[]

What to draw, in order; colors default to --chart-1 … --chart-5. Required.

—
stackedboolean

One bar per column with every series in it, its height their total; otherwise side by side.

false
radiusnumber

Corner radius of a bar's end; the end on the axis stays square.

4
heightnumber

In pixels, axes included; the width follows the container.

260
formatOptionsIntl.NumberFormatOptions

How values are written in the tooltip, e.g. { style: "currency", currency: "USD" }; the axis writes them compactly.

—
timeFormatIntl.DateTimeFormatOptions

Reads the index as dates and writes them like this.

—
showLegendbooleanmore than one series
showGridboolean

Dashed lines at the axis values.

true
showYAxisboolean

The values along the left.

true
localestringthe LocaleProvider's
aria-labelstring

What the chart shows, e.g. “Revenue by month”.

"Trend from … to …"
classNames{ legend, tooltip }—

Keyboard

KeysAction
TabFocus the chart
←or→Read the previous or next point
HomeorEndThe first or last point
EscStop reading

Accessibility

  • A group named by your label (by default, how the first series went); the point you move to with the arrow keys is read out with every series' value.
  • The x axis runs left to right in every language, as on most charts; the legend and tooltip follow the page's direction.
  • The tooltip lists every series by name, so nothing depends on telling colors apart.

Motion

  • The bars grow up from the axis when it first shows, and to their new heights when the data changes. Instant with reduced motion.