shadcn bar charts are feasible for almost any static or lightly interactive comparison: vertical, horizontal, grouped, stacked, 100% stacked, negative, floating ranges, waterfalls and bar-plus-line combinations all work with the stock chart component. Three limits decide whether they fit your project. They render no SVG on the server, so the chart is absent from your initial HTML. They add roughly 94 to 123 KB of gzipped JavaScript on top of React. And on narrow screens they silently hide category labels. This guide shows the patterns I tested, the code for the ones that aren't obvious, and how to work around each limit.
I needed charts for a small Astro site where most pages ship almost no JavaScript, so I wanted real numbers before adding a charting library. The shadcn gallery shows what the charts look like. It doesn't tell you what lands in your HTML, what it costs in bytes, or what happens at 343 pixels wide. So I built every bar pattern I could think of in a throwaway project and measured it.
What I tested: Recharts 3.8.0 (the version the shadcn registry pins at the time of writing; npm's latest is 3.10.1, which I did not test), React 19, Tailwind CSS v4, and a production Astro 7 build for the real-world bundle figure. I did not run these tests inside a Next.js app. Timings come from one machine and are useful for comparing against each other, not as absolute numbers.
The short verdict
What you are actually installing
The chart component is a thin wrapper, not a charting engine. Recharts draws everything. shadcn adds ChartContainer for sizing and colour variables, plus styled tooltip and legend components.
bash
npx shadcn@latest add chart
That adds components/ui/chart.tsx and installs Recharts. Because the CLI copies the file into your project, you own it and can edit it. In my Astro project, where rsc is false, the CLI removed the "use client" line from the file. In a React Server Components project the registry version keeps it, and any component using these charts has to be a client component.
Here is the base pattern every example below builds on.
ChartConfig is the part worth understanding. Each key becomes a scoped CSS variable, so revenue in the config gives you var(--color-revenue) inside the chart. Labels in the tooltip and legend also come from this object, which keeps your data free of display strings.
The explicit height matters too, and I'll come back to it in the error section.
Every bar pattern I tested
Seventeen bar chart patterns rendered with the shadcn chart component and Recharts 3.8.0
All of these rendered correctly with no console errors, and all use ChartContainer unchanged.
Most of these translate directly from the table. Three deserve code, because the obvious approach is either deprecated or not obvious at all.
Highlight one bar without using Cell
Many Recharts examples, and probably some of your existing code, colour individual bars with <Cell>. The Recharts 3.8.0 type definitions mark it as deprecated and say it will be removed in Recharts 4.0.
For a static highlight, you don't need a replacement component. Put a fill value on the row.
Recharts reads fill from each row, so no extra markup is needed. This is what I'd reach for first, because the colour logic stays with the data and you avoid a future migration. The negative-value chart in my test used it to colour losses differently from gains.
Make a bar respond to clicks
When the colour depends on state, use the shape prop, which is the replacement the Recharts deprecation notice recommends.
shape hands you each bar's computed geometry, and Rectangle draws it, including any radius. Since you control the render, you can also draw something other than a rectangle.
Floating bars and waterfalls
If a data value is a two-item array, Recharts draws the bar between those two numbers. That single behaviour gives you both timelines and waterfalls.
There's no dedicated waterfall type, so you calculate the running totals yourself. You also don't get connector lines between the steps. If those matter, you'll need to draw them yourself with a custom shape.
The first limit: nothing renders on the server
This is the finding that surprised me most. I ran a complete chart through React's renderToString and got 1,240 characters of output containing zero <svg> elements, zero bars and zero axis labels. Only the empty container and its style tag come through.
Recharts needs to measure its container before drawing, and on the server there's nothing to measure. So the chart appears only after JavaScript runs in the browser, and your numbers aren't in the initial HTML. Search engines that don't execute JavaScript, AI crawlers, and readers with JavaScript disabled or failing all get an empty box.
The fix is to keep the chart as an enhancement rather than the only place the data lives.
tsx
<figure>
</figure>
In a framework that renders this component on the server, the table is in the HTML and the chart fills in on top of it. If the numbers matter for search, render the table from a server component or an .astro file, so it stays in the output even if you load the chart client-only. It solves the accessibility problem covered below as well.
If you need a real server-rendered graphic, Recharts is the wrong tool for that specific chart. A small handwritten SVG or a few styled div elements will serve a three-bar comparison with no JavaScript at all.
The second limit: bundle size
I measured the gzipped size of the JavaScript each setup adds, leaving out React itself.
Setup
Gzipped size
Two conclusions follow. The first bar chart is the expensive part, and it costs more than React itself. Every additional chart type after that is cheap: adding five other families cost only about 24 KB in the same bundler. So don't choose a worse chart type to save bytes once Recharts is on the page.
The figures also differ by bundler, so treat them as a range and measure your own build.
How you load the chart matters more than the exact number. Keep it out of pages that don't use it, and delay it where you can.
Whichever you use, reserve the chart's height in the layout so the page doesn't jump when it appears. I confirmed client:load works in Astro in my test, and I'd use client:visible in production, though I did not measure it separately.
The third limit: narrow screens
I rendered eight categories with realistic labels such as "Regional hospital outpatient" in a 343-pixel container, roughly a phone with page padding. The vertical bar chart showed only 2 of the 8 labels. All eight bars were still there, but six had no name, and there was no warning. Recharts hides ticks that would collide.
The same data in a horizontal layout displayed all eight labels, wrapped onto multiple lines.
width sets the room reserved for the labels, and interval={0} tells Recharts to keep every one. My rule now: if your category names are longer than a word or two, or there are more than a handful, start with horizontal bars. You'd probably want them there anyway, since a long label is easier to read next to its bar.
Value labels have a related trap. In my negative-value chart, position="top" placed the label for the tallest bar 11 pixels above the top of the SVG, so it disappeared. The value existed in the DOM but wasn't visible. When you use LabelList, add room with margin={{ top: 24 }} on BarChart, and check the tallest bar specifically.
The fourth limit: accessibility needs finishing
The shadcn docs say you can turn on accessibilityLayer, but in Recharts 3 it's already on by default: CartesianChart sets it to true, and every chart in my test rendered with role="application" and tabindex="0", including the ones where I left the prop out.
The keyboard support is real. I focused a chart, pressed the right arrow twice, and the tooltip moved to the third bar and displayed "Mar Alpha 237".
What's left for you to add:
A name. The SVG had no aria-label, and the only text inside it was the axis labels. Bar values aren't in the DOM until a tooltip shows them. The sr-only table above addresses this.
Animation is one thing you don't need to handle. isAnimationActive defaults to "auto", and the Recharts source turns animation off when the user prefers reduced motion. For charts that update often or sit in print views, I set it to false explicitly.
How far can you push the data?
I rendered increasing numbers of bars at 1,000 pixels wide, with animation off, and timed them until they were on screen.
Performance wasn't the real limit. Recharts draws SVG, not canvas, and each bar costs about three DOM nodes, so 5,000 bars is heavy but workable on a fast machine. Slower phones will suffer sooner, and I didn't test those.
Readability gives out long before that. At 5,000 bars across 1,000 pixels, each bar gets a fifth of a pixel and the chart turns into a blur. For dense data, aggregate first, use Brush to show a window, or switch to a line or area chart. Once you truly need thousands of marks visible at once, a canvas-based library is a better fit.
Zero values disappear
My 5,000-bar test rendered 4,950 rectangles. The missing 50 were the rows with a value of zero, which get no rectangle at all. Usually that's correct, but it can hide the very point of your chart if you want to show "budgeted 15,000, spent 0".
You have two options. minPointSize={4} forces a 4-pixel sliver, which I measured working, but it then shows a small bar for something that's actually nothing. background={{ fill: "var(--muted)" }} draws an empty track behind each bar, which makes an empty bar look intentional without misrepresenting the value. I prefer the track, along with a printed value label.
Numbers and colours
The default tooltip formats values with toLocaleString() and no locale, so it follows the visitor's browser instead of your page. On a Slovenian site, that can show 27.5 where you want 27,5. Set the format explicitly.
I verified this renders 27,5 %. Note that formatter replaces the whole tooltip row, including the colour indicator and series name, so include anything you want to keep. Use the same formatter on the axis tickFormatter and on LabelList, or your labels will disagree with your tooltip.
Colours have a similar quiet trap. --chart-1 to --chart-5 come from your shadcn preset, not your brand. On my project, they were five shades of olive on an otherwise blue site. Check those variables before your first chart, and retune them in your global CSS. With Recharts 3, reference them as var(--chart-1), without the hsl() wrapper older shadcn examples used. Single-series comparison charts often read better with just your primary colour and one neutral.
The width(0) and height(0) of chart should be greater than 0
If you see this warning in the console and an empty space where your chart should be, your container has no measurable size:
text
The width(0) and height(0) of chart should be greater than 0,
please check the style of container, or the props width(100%) and height(100%),
or add a minWidth(0) or minHeight(undefined) or use aspect(undefined) to control the
height and width.
I got this warning on a test page that didn't load my global stylesheet, so Tailwind's sizing classes did nothing. I got the same empty chart from a new height class that wasn't in my CSS yet, because the stylesheet was built before I added the file. Both looked like Recharts bugs until I found the cause.
Check three things: that ChartContainer has a height, min-h-* or aspect-* class, that the class exists in your compiled CSS, and that no parent is hidden or zero-width. A chart in a closed tab or collapsed panel has nothing to measure either. When I ran the test in a hidden browser pane, with a viewport width of 0, no chart drew at all until I gave it a size.
When to use something else
Tooltips and interactivity are the real test. If your chart doesn't need them, you're paying about 100 KB for a picture. If you're already showing data in tables, my guide on choosing between the shadcn Table and Data Table covers the matching decision for rows and columns.
FAQ
Do shadcn charts work with server-side rendering?
They don't break it, but they don't render on the server either. My renderToString test produced only an empty container, so the SVG appears after the browser runs JavaScript. Provide the data as text or a table if it must be in your HTML.
How much do shadcn charts add to my bundle?
I measured 94 KB gzipped for one bar chart in a production Astro build, and 123 KB with esbuild, excluding React. Adding every other chart type added only about 24 KB more.
Can I build a waterfall or Gantt chart with shadcn?
Yes. Pass a [start, end] array as the bar's data value and Recharts draws a floating bar. Waterfall connector lines aren't built in, and you calculate the running totals yourself.
Should I still use Cell to colour bars in Recharts 3?
Avoid it in new code. It's marked deprecated and scheduled for removal in Recharts 4.0. Put a fill value on each data row for static colours, and use the shape prop for anything that depends on state.
Why are some of my axis labels missing on mobile?
Recharts hides ticks that would overlap. In my test, a vertical bar chart showed 2 of 8 long labels at 343 pixels. Switch to layout="vertical" and set interval={0} with a suitable YAxis width.
Conclusion
shadcn bar charts handle nearly every comparison a typical product or content site needs, and the 15 patterns above all worked with the stock component. The real decisions aren't about chart types. They're about the fact that the chart isn't in your server HTML, that the first one costs about 100 KB, that long labels vanish on phones, and that accessibility needs a final pass from you.
If you plan for those four things up front, with a table alongside the chart, lazy loading, horizontal bars for long labels, and a visible focus style, you get a solid charting setup you fully own. If your chart is three static bars, skip the library and write the SVG.
Let me know in the comments if you have questions or have measured something different on your stack, and subscribe for more practical development guides.
Thanks,
Matija
Written by Matija Žiberna, a developer building production web applications with Next.js, Astro and Payload CMS. Tested on Recharts 3.8.0, React 19, Tailwind CSS v4 and Astro 7. Sources: shadcn chart documentation, shadcn chart gallery and the Recharts 3.8.0 package source. Last updated 6 November 2026.
Requirement
Feasible?
What to know
Standard bar variants
Yes
The gallery lists 10 bar variants; all are copyable patterns, not separate installs
A visible focus indicator.ChartContainer applies outline-hidden to the chart surface. Keyboard users can reach the chart, but they can't see that they have. Since you own chart.tsx, you can add a focus-visible style to that surface.
Bars
Render time
DOM nodes
50
27 ms
179
500
31 ms
1,529
2,000
111 ms
6,029
5,000
272 ms
15,029
Situation
Better choice
A few bars, no interaction, content-heavy page
Handwritten SVG or CSS bars, with no JavaScript
Chart must exist in server HTML or an email
Server-generated SVG or an image
Print or PDF output
A print-specific tool. Recharts draws in the browser, and its fills rely on CSS variables
Thousands of visible marks
A canvas-based charting library
Dashboards, filters, tooltips, several chart types