DocsComponentsTemplatesThemesGitHub

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.json

Guidelines

  • 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.
  • stacked for part-to-whole over categories.

Props

PropTypeRequired
widthnumberNo
labelsstring[]Yes
seriesArray<{ name: string; data: number[]; color?: string }>Yes
stackedbooleanNo
heightnumberNo
titleReact.ReactNodeNo
subtitleReact.ReactNodeNo
format(v: number) => stringNo
xLabelstringNo
allowTablebooleanNo
classNamestringNo
styleReact.CSSPropertiesNo

Edit this example on GitHub