Xzero UI
Pro library

Bar chart

Compare one measure across days and scrub any bar for its value.

$ pnpm dlx shadcn@4.23.0 add @xzero-ui/bar-chart
Live · keyboard ready

When to use

When not to use

Installation

Register both Xzero UI namespaces in your project's components.json:

{
  "registries": {
    "@xzero-ui": "https://mcp.xzero.co.uk/r/{name}.json",
    "@xzero-ui-pro": "https://mcp.xzero.co.uk/r/pro/{name}.json"
  }
}
npx shadcn@4.23.0 add @xzero-ui/bar-chart

Install xzero-foundation once, and import @/components/xzero/foundation.css in your app root. No Xzero token is used by this snapshot. For sample portraits, photos, fonts, or logos, download https://mcp.xzero.co.uk/install-assets.mjs and run node xzero-install-assets.mjs <receiving-project>.

Usage

import { BarChart } from "@/components/xzero/bar-chart/bar-chart";

const week = [
  { key: "2026-09-14", label: "Mon, Sep 14", axisLabel: "M", value: 32 },
  { key: "2026-09-15", label: "Tue, Sep 15", axisLabel: "T", value: 48 },
  { key: "2026-09-16", label: "Wed, Sep 16", axisLabel: "W", value: 27 },
];

export function ActiveMinutes() {
  return <BarChart data={week} label="Active minutes" period="Sep 14–16, 2026" unit="min" />;
}

API reference

BarChart

A single series column chart with an average line and a scrubbable headline value.

PropTypeDefaultDescription
data (required){ key: string; label: string; axisLabel?: string; value: number }[]–Bars in order. A surviving key keeps its bar, so range switches morph.
label (required)string–What is measured, such as "Active minutes".
period (required)string–Range on show, under the headline.
unitstring""Unit after each value, such as "min".
averageLabelstring"Daily average"Headline label at rest.
valueLabelstring"Total"Headline label while a bar is scrubbed.
categoryLabelstring"Day"First column header in the screen reader table.
showAveragebooleantrueDraws the average as a reference line.
heightnumber176Plot height in pixels.
formatValue(value: number) => string–Formats values and ticks. Defaults to a grouped number.

Keyboard interactions

KeysAction
ArrowLeft / ArrowRightMoves between bars (ArrowDown and ArrowUp too).
PageDown / PageUpMoves up to seven bars.
Home / EndJumps to the first or last bar.
EscapeStops scrubbing and returns to the average.

Accessibility

Motion

Responsive behavior

Performance

Notes for AI

Also in charts

Guidance for AI tools

Bar chart: Compare one measure across days and scrub any bar for its value. Follow the declared prop types and do not invent props. Keep keyboard access, reduced motion support, and both light and dark themes intact when adapting it.

Full library index: https://ui.xzero.co.uk/llms.txt

Browse all components