Bar chartPro
Bars that grow in and morph between datasets, with a hover readout.
$
pnpm dlx shadcn@latest add @lode/bar-chartLive preview
Orders
When to use
- Comparing one measure across categories or periods.
When not to use
- Trends over many points: use a line or area chart.
Installation
$
pnpm dlx shadcn@latest add @lode/bar-chartPro components need an API key and the registry in components.json. See CLI and API keys.
1Install the dependencies
npm install motion2Copy the source into your project
Usage
Import it from @/components/ui/bar-chart after installing.
example.tsx
import { BarChart } from "@/components/ui/bar-chart";
export function Orders() {
return <BarChart data={[{ label: "Mon", value: 420 }, { label: "Tue", value: 512 }]} height={220} />;
}API reference
BarChart
Vertical bars with a y-axis and hover readout.
data
{ label; value; color? }[]
Bars in order.
height= 240
number
Height in px.
yTicks= 3
number
Axis labels.
formatValue / color
(n) => string / string
Tooltip format and default bar color.
| Prop | Type | Default | Description |
|---|---|---|---|
| data | { label; value; color? }[] | – | Bars in order. |
| height | number | 240 | Height in px. |
| yTicks | number | 3 | Axis labels. |
| formatValue / color | (n) => string / string | – | Tooltip format and default bar color. |
Accessibility
- role="img"; summarize the key comparison in text.
Motion
- Bars grow from the baseline with a small stagger and morph between datasets.
Responsive behavior
- Measures its width; labels thin out above 12 bars.
Performance
- One rect per bar.
Notes for AI
- Keep labels short; they sit under each bar.
This page as Markdown, for assistants and coding agents:
/components/bar-chart/markdownThe full library index for assistants is at /llms.txt.
Related
Lode·229 doc pages·llms.txt