Chart
Responsive charts with theme-aware series and a text alternative.
Installation
Add the component and its dependencies from the registry running on your computer.
npx shadcn@latest add https://brutallab.facilito.dev/r/chart.jsonUsage
Import the component into your project and keep the source code under your control.
'use client';
import {
ChartContainer,
ChartTooltip,
ChartTooltipContent,
} from '@/components/ui/chart';
import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from 'recharts';
export default function Demo() {
const data = [
{ week: 'W1', count: 4 },
{ week: 'W2', count: 7 },
{ week: 'W3', count: 10 },
{ week: 'W4', count: 12 },
];
return (
<div className="w-full">
<p className="mb-4 bl-type-label">Components used per week</p>
<ChartContainer
config={{ count: { label: 'Components', color: 'var(--primary)' } }}
className="h-56 w-full"
>
<BarChart accessibilityLayer data={data}>
<CartesianGrid vertical={false} />
<XAxis dataKey="week" />
<YAxis allowDecimals={false} />
<ChartTooltip content={<ChartTooltipContent />} />
<Bar dataKey="count" fill="var(--color-count)" radius={4} />
</BarChart>
</ChartContainer>
<p className="bl-type-small">
Week 1: 4; Week 2: 7; Week 3: 10; Week 4: 12.
</p>
</div>
);
}
States & interaction
Appearance, behavior and keyboard checks.
- The composition inherits its controls’ states. Test empty, content, loading and error cases where the application needs them.
- Examples on this page are runnable; the displayed code uses the same components. Business logic belongs to the consumer.
- Test the example with Tab and Shift+Tab. Focus must stay visible in both themes.
API Reference
BrutalLab-specific properties. Native attributes are supported as well.
| Prop | Type | Default | Description |
|---|---|---|---|
| config | ChartConfig | — | Names, icons, and colors for each series. |
Accessibility
Rules that should remain intact when adapting the component to a product.
Provide a text summary or equivalent table. Color and tooltip interaction must not be the only way to read the data.
Retain keyboard focus styles and test the composition with keyboard navigation.
Use className for visual customization; preserve the primitive ARIA attributes.