Bar Chart

Loading...

Installation

Add the component with the CLI.

npx shadcn@latest add @intentui/bar-chart

Composed components

When you install this component via the CLI, it automatically loads all composed components, so you don’t need to add them individually.

Manual installation

Install the dependencies, then copy the component source into your project.

npm install recharts react-aria-components

Examples

Stacked

Stack series within each bar to compare their contributions across categories.

Loading...

Custom format

Use valueFormatter and a tooltip formatter to display numeric values in a custom format.

Loading...

Custom tooltip

Use a custom tooltip to display values, labels, and icons when users hover over a bar.

Loading...

Custom legend

Use a custom legend to identify series with labels, colors, or icons.

Loading...

Custom colors

Set series colors in the chart configuration.

Loading...

Controlled

Manage chart state to filter data or switch between views.

Loading...

Component API

BarChart extends the internal Intent UI <BaseChart> component.

barCategoryGapnumber
Default: 5
barGapnumber
barPropsPartial<React.ComponentProps<typeof Bar>>
barRadiusnumber
barSizenumber
cartesianGridPropsCartesianGridProps
chartPropsOmit<ComponentProps<typeof BarChartPrimitive>, "data" | "stackOffset">
childrenReact.ReactNode
classNamestring
colorsreadonly (ChartColorKeys | string)[]
Default: DEFAULT_COLORS
configChartConfig
containerHeightnumber
Default: 370 desktop / 200 mobile
dataRecord<string, any>[]
Default: []
dataKeystring
displayEdgeLabelsOnlyboolean
Default: false
hideGridLinesboolean
Default: false
hideXAxisboolean
Default: false
hideYAxisboolean
Default: false
intervalTypeIntervalType
Default: equidistantPreserveStart
layoutChartLayout
Default: horizontal
legendLegendContentType | boolean
Default: true
legendPropsOmit<ComponentProps<typeof LegendPrimitive>, "content" | "ref">
tooltipTooltipContentType<ValueType, NameType> | boolean
Default: true
tooltipPropsBaseChartProps["tooltipProps"]
typeChartType
Default: default
valueFormatter(value: number) => string
Default: (value) => value.toString()
xAxisPropsXAxisPropsPrimitive
yAxisPropsYAxisPrimitiveProps

See the Recharts for the full API reference.

Design