shadcn.io is not affiliated with official shadcn/ui
About
Use it for one number with a sense of progress: a quota, a daily goal, storage used. The ring gives the card a shape, the center gives the value. For two parts of a total, the stacked radial chart splits the same ring; for a share of a whole, a donut with text.
A thin ring with rounded ends sweeps 250 degrees counterclockwise from three o'clock over a muted track. The value, 200, sits large in the center with Visitors under it.
Installation
Usage
import { ChartRadialText } from "@/components/charts/chart-radial-text";<ChartRadialText />Customize
<RadialBarChart startAngle={0} endAngle={250} innerRadius={80} outerRadius={90}>sets the sweep and the ring's thickness.<PolarGrid polarRadius={[90, 80]} />withfirst:fill-muted last:fill-backgroundpaints the track;stroke="none"andradialLines={false}hide its lines.<RadialBar background cornerRadius={10} dataKey="visitors" />draws the rounded ring.- A
<Label>in<PolarRadiusAxis>drawschartData[0].visitors.toLocaleString()andVisitorsat the center.
FAQ
How do I make the ring show progress toward a goal?
Recharts fits the angle axis to the one value, so the bar always fills startAngle={0} to endAngle={250}. Add <PolarAngleAxis type="number" domain={[0, goal]} tick={false} /> and set endAngle to 360 for a ring that fills toward a goal.
How is the gray track drawn?
<PolarGrid gridType="circle" polarRadius={[90, 80]} radialLines={false} stroke="none" /> draws two circles; first:fill-muted last:fill-background fills the outer one muted and covers its middle with the background, leaving a ring.
How is the text in the center drawn?
A <Label> inside <PolarRadiusAxis axisLine={false} tick={false} tickLine={false}>. Its content reads viewBox.cx and viewBox.cy and returns a <text> with two <tspan>s: the value in fill-foreground font-bold text-4xl, Visitors in fill-muted-foreground.
API Reference
ChartContainer
configChartConfig
Each series by its data key: its label, an icon, and a color (or a * theme color per light and dark), read by the tooltip and legend and set * as --color-<key>.
initialDimension?{ height: number; width: number; }
The size it renders at before it's measured, so the first paint isn't * empty.
- Type
{ height: number; width: number; }- Default
INITIAL_DIMENSION
className?string
Merged with the part's classes.
ChartLegend
ChartLegendContent
<div>
hideIcon?boolean
Hides each series' icon (from config), leaving its color swatch.
- Default
false
nameKey?string
The key in each legend item's data to look its label up by in config. * Defaults to the item's dataKey.
className?string
Merged with the part's classes.
ChartStyle
<style>
configChartConfig
The chart config whose colors it writes as --color-<key> variables.
idstring
The element's id.
ChartTooltip
ChartTooltipContent
<div>
hideIndicator?boolean
Hides each item's color indicator.
- Default
false
hideLabel?boolean
Hides the tooltip's label, the hovered point's.
- Default
false
indicator?"dashed" | "dot" | "line"
The color indicator's shape: a dot, a line or dashed.
- Type
"dashed" | "dot" | "line"- Default
"dot"
labelFormatter?(label: any, payload: TooltipPayload) → React.ReactNode
Formats the tooltip's label; its value is untyped, as in recharts 3.8.
- Type
(label: any, payload: TooltipPayload) → React.ReactNode- Parameters
label– anypayload– TooltipPayload- Returns
React.ReactNode
labelKey?string
The key in the data to read the label from, looked up in config.
nameKey?string
The key in each item's data to look its name up by in config.
className?string
Merged with the part's classes.
Related
Radial Chart with Custom Shape
Radial chartsA thick ring with a custom end angle and the total inside.
Stacked Radial Chart
Radial chartsTwo series stacked on a half ring, with their total.
Donut Chart with Text
Pie chartsA donut with the total written in its center.
Radial Chart
Radial chartsOne ring per browser, each as long as its share.
Area Chart
Area chartsOne series as a smooth filled curve over six months.
Radial Chart with Labels
Radial chartsRadial bars with each browser's name written at its start.