Stop Rebuilding UI

Shadcn.io is not affiliated with official shadcn/ui

A pie chart with a legend

A React pie chart with legend component for category identification separate from the chart using shadcn/ui and Recharts

Legends solve the label problem. This React pie chart uses ChartLegend and ChartLegendContent components to display category names with color indicators below the chart, keeping the pie itself clean and uncluttered. Built with shadcn/ui and Recharts, the legend uses flex-wrap with basis-1/4 for responsive multi-row layout, showing each browser with its corresponding color swatch. This approach works better than on-chart labels when you have many categories, long category names, small slices where labels don't fit, or when you want a minimal aesthetic. Perfect for dashboards, reports, or any visualization where spatial efficiency and clean design matter.

A pie chart with a legend preview

Scroll to load preview

Installation

FAQ

Was this page helpful?

Sign in to leave feedback.