Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Chart examples · Radial

A radial chart for React

A radial bar chart with one ring per browser over a muted background track.

Framework
UI library

Radial bars: one ring per browser, its arc as long as its value, over a muted background track. The tooltip names the browser and its count.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.

FAQ

How do I set the hole and the outer edge?

RadialBarChart sets innerRadius={30} and outerRadius={110}. The five browser rows share that band. Each row's visitors value is how far that arc runs. Chrome is 275 and Other is 90.

What does background draw?

RadialBar sets background and dataKey="visitors". background draws the full-circle track behind each arc, and the chart styles that sector with the muted fill. The colored part is the visitors value.

How does the tooltip name a ring?

ChartTooltipContent sets hideLabel and nameKey="browser". hideLabel drops the title. nameKey reads the row's browser field and looks it up in config, so the row says Chrome, Safari, Firefox, Edge, or Other. cursor={false} turns the hover cursor off.

Where does each ring's color come from?

Each chartData row sets fill to var(--color-chrome) or the matching key. config maps those keys to var(--chart-1) through var(--chart-5), and ChartContainer writes the --color- variables. visitors in config is only the label Visitors.

How do I add another browser?

Add a row to chartData with browser, visitors, and fill, and add a matching entry in config with a label and a color. RadialBar already maps dataKey="visitors" across the whole array. This file doesn't set startAngle or endAngle, so the track is a full circle.

How do I keep it square?

ChartContainer sets mx-auto aspect-square max-h-[250px] inside a w-full max-w-xl frame. That overrides the container's default 16:9 box.