BarChart
Grouped or stacked bars on one axis with hover tooltip, legend (2+ series) and a table view.
Code
import * as React from 'react';
import { BarChart } from '@fruit-labs/design';
export default function Demo() {
return (
<BarChart
title="Signups by plan"
subtitle="Last 6 months · sample data"
labels={['Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']}
series={[
{
name: 'Free',
data: [120, 150, 170, 160, 210, 240],
},
{
name: 'Pro',
data: [40, 52, 61, 70, 82, 95],
},
]}
/>
);
}Stacked
import { BarChart } from '@fruit-labs/design';
export default function Example() {
return (
<div style={{ display: 'flex', flexDirection: 'column', gap: 12, maxWidth: 560 }}>
<BarChart stacked title="Signups" labels={['Q1', 'Q2', 'Q3']} series={[{ name: 'Free', data: [40, 55, 70] }, { name: 'Pro', data: [12, 20, 31] }]} />
</div>
);
}Install
From npm:
npm install @fruit-labs/design
import { BarChart } from '@fruit-labs/design';Or copy the TypeScript source into your project:
npx shadcn@latest add https://design.fruitlabs.online/r/bar-chart.jsonGuidelines
- Colors come from --chart-1…5 in fixed order; 6+ series fold into Other.
- Bars start at zero; values in tooltip, not on every bar.
stackedfor part-to-whole over categories.
Props
| Prop | Type | Required |
|---|---|---|
width | number | No |
labels | string[] | Yes |
series | Array<{ name: string; data: number[]; color?: string }> | Yes |
stacked | boolean | No |
height | number | No |
title | React.ReactNode | No |
subtitle | React.ReactNode | No |
format | (v: number) => string | No |
xLabel | string | No |
allowTable | boolean | No |
className | string | No |
style | React.CSSProperties | No |