When to use a horizontal bar chart
Horizontal bars beat vertical ones when labels are long or when the point of the chart is the ranking.
- Top pages, products, or customers
- GitHub stars or downloads by library
- Survey answers with long option text
- Leaderboards that should read top to bottom
Data format
- Column 1 holds the labels shown down the left side; the label width adapts to your longest label.
- Add more columns for grouped or stacked horizontal bars.
- Paste CSV, JSON from your API, TSV copied from Excel or Google Sheets, or a Markdown table. The generated component keeps your column names as its data keys.
Framework,Stars
React,232000
Vue,208000
Angular,96000
Svelte,80000
Solid,33000
Qwik,21000[
{"framework": "React", "stars": 232000},
{"framework": "Vue", "stars": 208000},
{"framework": "Angular", "stars": 96000},
…
]Options
- Sort
- Keep your order, or sort high → low or low → high. Props-mode code sorts at render time.
- Values
- Show each bar's value at its end.
- Grouped / Stacked / 100%
- Available when you have more than one series.
How to add it to your project
- 1. Add the shadcn/ui chart component (it installs Recharts):
npx shadcn@latest add chart - 2. Paste your data above, pick the options, and copy the generated
chart.tsx. - 3. Save it in your project (e.g.
components/horizontal-bar-chart.tsx) and render<Chart />, or<Chart data={rows} />in Data as prop mode.
Horizontal Bar Chart FAQ
Set layout="vertical" on BarChart, put the category on a YAxis with type="category", and use a numeric XAxis. ChartCN generates exactly that, with sorting and labels wired up.
Yes. Choose High → low or Low → high. With inline data the rows are pre-sorted; with Data as prop the component sorts incoming data itself.
Long category names don't fit under vertical bars, and rankings are easier to scan top to bottom. For time series, vertical bars are usually the better fit.