Controls

Horizontal Bar Chart

Effect
Preview
Reduced motion

Simulates prefers-reduced-motion for the demo. Off follows your system setting.

Keyboard stepping

Steps focus through the demo with ] and [. Tab, arrows, and Escape stay native so the component behaves as shipped.

Horizontal Bar Chart
Visitors by country
  • United States4.1K
  • Germany2.4K
  • India2K
  • Brazil1.2K
  • Japan860

Horizontal Bar Chart

A ranked list of labelled bars that fill along soft rounded tracks.

Installation

npx shadcn@latest add ikislay/pixel-ui/horizontal-bar-chart

How to use

import { HorizontalBarChart } from "@/components/ui/horizontal-bar-chart"
const data = [
{ label: "United States", value: 4120 },
{ label: "Germany", value: 2380 },
{ label: "India", value: 1960 },
]
export function Demo() {
return <HorizontalBarChart label="Visitors by country" data={data} />
}

Source Code

// Loading…

Props

Options you can pass to customize this component.

Prop
Type
Description
data*
{ label: string; value: number; color?: string }[]

One row per entry, drawn in the order given.

label*
string

Names the chart for screen readers and captions its data table.

format
(value: number) => string

Formats values wherever the chart shows them. Defaults to short numbers like 12.4K.

max
number

The value that fills a track. Defaults to the largest value.

color
string

Any CSS color for the bars. A row's own color wins.

className
string

Merged onto the root element.