shadcn.io is an independent project built on shadcn/ui
On this page16 sections
Installation
The command adds the example above to components/charts/ and, the first time, the chart kit to components/ui/charts/. Both are source files in your project from then on: read them, change them, delete what you don't use.
Usage
metrics lists the spokes, clockwise from 12 o'clock. Each series has a label and a values record keyed by metric. The scale is fixed at 0 to 100 and values outside it are clamped, so convert yours to scores first.
import {
RadarArea,
RadarAxis,
RadarChart,
RadarGrid,
RadarLabels,
} from "@/components/ui/charts";
const metrics = [
{ key: "speed", label: "Speed" },
{ key: "uptime", label: "Uptime" },
{ key: "support", label: "Support" },
{ key: "price", label: "Price" },
{ key: "docs", label: "Docs" },
];
const data = [
{
label: "Vendor A",
values: { docs: 70, price: 55, speed: 88, support: 62, uptime: 95 },
},
{
label: "Vendor B",
values: { docs: 85, price: 80, speed: 64, support: 90, uptime: 82 },
},
];
export const VendorRadar = () => (
<RadarChart
ariaLabel="Two vendors scored out of 100"
data={data}
metrics={metrics}
size={360}
>
<RadarGrid />
<RadarAxis />
<RadarLabels />
{data.map((item, index) => (
<RadarArea index={index} key={item.label} />
))}
</RadarChart>
);Anatomy
Each part is a child you include or leave out. The chart layers them in a fixed order, so the grid stays at the back and the series on top wherever you write them.
<RadarChart data={data} levels={4} metrics={metrics}>
<RadarGrid showLabels={false} />
<RadarAxis />
<RadarLabels interactive />
<RadarArea index={0} showGlow />
<RadarArea color="var(--chart-3)" index={1} showPoints={false} />
</RadarChart>RadarChart: Holdsdataandmetricsand lays out one spoke per metric, clockwise from 12 o'clock.RadarGrid: The concentric rings,levelsof them, with their values along the first spoke.RadarAxis: A line from the center out to each metric.RadarLabels: The metric names around the outside.RadarArea: One series byindex: a filled polygon with an outline and a dot on each value.
Hover and highlight
The pointer picks the polygon under it. That series grows by 5% and fills in more strongly while the others fade to 30%, and showGlow on its <RadarArea> adds a soft shadow in its color.
hoveredIndex and onHoverChange make the hover controlled, so you can name the hovered series outside the chart, as this one does under it. <RadarLabels interactive /> dims the metric names and brightens the one under the pointer.
With a legend
ChartLegend takes the same hoveredIndex and an onHover callback, so a row and its polygon light up together from either side. Its items are yours to compute: here, each campaign's average score.
Grid rings and spokes
levels sets the number of grid rings (5 by default), each an equal step of the 0 to 100 scale. The ring values are printed as they come, so with levels={3} you'd read 33.333333333333336: pick 4, 5 or 10, or pass showLabels={false} to <RadarGrid>.
Leave out <RadarAxis /> to drop the spokes, and <RadarGrid /> as well for a polygon with only its labels.
Fills, outlines and dots
Each <RadarArea> draws a fill, an outline and a dot on every value. showStroke={false} and showPoints={false} take away the last two, which keeps two overlapping series easy to tell apart.
Customization
The kit is in your project, in components/ui/charts/: your framework's components over a shared core/. Change a default there and every chart picks it up.
className goes on the chart's container, so size and spacing are utility classes.
Radar parts have no render props. You set them up with props, and every color is a CSS value: color on a <RadarArea> wins over the data item's color, which wins over the palette.
The grid and spokes take stroke and strokeOpacity, the labels fontSize and offset. margin (60) is the room the chart keeps around the grid for the labels, so lower it when your metric names are short.
<RadarChart data={data} margin={40} metrics={metrics}>
<RadarGrid showLabels={false} stroke="var(--chart-1)" strokeOpacity={0.25} />
<RadarLabels fontSize={12} offset={16} />
<RadarArea color="var(--chart-4)" index={0} showStroke={false} />
</RadarChart>Loading state
There's no loading state. Until the scores arrive, a square Skeleton the size of the chart keeps its place in the layout.
Animation
The grid rings expand from the center, the spokes grow out and the labels glide into place. Then each polygon grows from the center, 150 ms after the one before.
enterDurationMs (1100) is the budget for the whole sequence, and staggerScale stretches the gaps between steps: 0 starts everything together. enterTransition swaps the polygons' tween for a spring.
Changing motionReplayKey plays the entrance again. animate={false} draws the finished chart on the first frame.
Theming
Every color in the kit is one of your theme's tokens or a mix of them, except --chart-positive, a fixed green. A preset or the .dark class restyles the chart, and overriding a token in your CSS changes it everywhere.
Series take --chart-1 to --chart-5 by index, or the color you give them. The grid and spokes are your theme's --border at 60% opacity.
Metric names use --chart-label and the ring values the softer --chart-foreground-muted.
| Token | Default | Paints |
|---|---|---|
--chart-1 | your theme's | the first series |
--chart-2 | your theme's | the second series |
--chart-3 | your theme's | the third series |
--chart-4 | your theme's | the fourth series |
--chart-5 | your theme's | the fifth series |
--chart-label | --muted-foreground | tick labels |
:root {
--chart-label: var(--foreground);
}Accessibility
The chart is an image named by ariaLabel ("Radar chart" by default). A polygon is hard to describe out loud, so put the comparison in ariaDescription: which series leads, and on what.
Focus steps through the series, not the metrics. Each step highlights one polygon the way hover does and calls onHoverChange.
- Tab
- Moves focus to the chart and highlights the first series.
- Arrow Right
- Moves to the next series. ArrowDown does the same.
- Arrow Left
- Moves to the previous series. ArrowUp does the same.
- Home
- Jumps to the first series.
- End
- Jumps to the last series.
FAQ
When should I use a radar chart instead of a bar chart?
Use a radar chart to compare a few profiles on the same measures when the overall shape is the point: where each one is strong, weak or lopsided. It needs at least three metrics to make a shape, and it reads best with two to four series.
Pick a grouped bar chart when readers must compare exact values, or when the metrics don't share a scale you can turn into scores. For two profiles, a dumbbell chart shows the gap on each metric directly.
What data does the radar chart need?
Two arrays. metrics lists the spokes, clockwise from 12 o'clock, each with a key and the label to print. data has one item per series: a label, an optional color and a values record with a number for each metric key.
Values run from 0 to 100, and a key missing from values counts as 0. A series is drawn only when you add a <RadarArea> with its index, so render one per item of data.
How do I plot values that aren't on a 0 to 100 scale on a radar chart?
Convert them to scores first. The radar's scale is fixed at 0 to 100 on every spoke and anything outside it is clamped, so 250 draws on the outer ring and a negative number at the center.
For each metric, divide the value by that metric's maximum or target and multiply by 100. Where lower is better, as with latency or price, invert the score so that further out always means better.
Keep the raw numbers in your own data to print them beside the chart.
How do I show a series' values on hover in a radar chart?
The radar chart has no tooltip. Hovering picks the polygon under the pointer: that series grows by 5% and the others fade to 30%.
To print its numbers, make the hover controlled with hoveredIndex and onHoverChange. The callback gets the series index, or null when the pointer leaves, so you can look the series up in your data and render its values under the chart.
<RadarLabels interactive /> also brightens the metric name under the pointer.
How do I add a legend to a radar chart?
Render a <ChartLegend> next to the chart and share one hovered index between them: hoveredIndex and onHoverChange on <RadarChart>, hoveredIndex and onHover on the legend. A row and its polygon then highlight together from either side.
The legend's items are yours to build, since a series holds a record of scores and not one number. Give each a label, a color and a value such as the series' average score, and format it with formatValue.
How do I change or hide the grid rings and spokes on a radar chart?
levels on <RadarChart> sets the number of rings, 5 by default, each an equal step of the 0 to 100 scale. <RadarGrid> prints each ring's value along the first spoke exactly as computed, so three levels read 33.333333333333336: choose 4, 5 or 10, or pass showLabels={false}.
Every part is optional. Leave out <RadarAxis /> to drop the spokes, <RadarGrid /> to drop the rings, and <RadarLabels /> for a bare polygon.
How do I keep overlapping series readable on a radar chart?
Start with fewer marks. showPoints={false} on a <RadarArea> removes its dots and showStroke={false} its outline, which leaves flat fills that are easier to tell apart.
Give each series a distinct color, on the data item or on its <RadarArea>: without one they take --chart-1 to --chart-5 by index. Hover does the rest, since the polygon under the pointer fills in more strongly while the others fade, and showGlow adds a soft shadow in its color.
How do I size a radar chart and make room for long metric labels?
Pass size for a fixed width and height in pixels, or leave it out and the chart fills its parent's width and stays square.
margin (60 px) is the room kept on every side for the metric names, so the grid's radius is half of size minus the margin: at 320 px the outer ring is 200 px across. Raise it when long names need more room, and lower it when they're short so the shape gets bigger.
<RadarLabels> takes offset, the distance from the outer ring (24 px), and fontSize (11).
Which frameworks does the radar chart support?
React, Vue, Svelte and Solid. One core on TanStack Charts draws the radar chart in each, so the components and props on this page are the same everywhere, and switching framework at the top of the page changes the preview, the code and the install command.
Only the spelling follows the framework: class for className outside React, scoped slots for render props in Vue and snippets in Svelte.
How do I add the radar chart to my project?
Sign in, then copy the command under Installation: npx shadcn@latest add with the chart's URL. It adds the example at the top of this page as components/charts/chart-radar-default, the chart kit to components/ui/charts the first time you install a chart, and @tanstack/charts.
Both are source files in your project from then on. Swap the sample rows for your own data and change whatever you need.
Is the radar chart free?
Yes. The radar chart and every example of it are free to use in personal and commercial projects. Seeing the code and installing it takes a free account, one tap with Google or GitHub.
The charts are bklit's (bklit-ui, MIT), rebuilt on TanStack Charts and drawn in your shadcn/ui theme's tokens.
API reference
RadarChart
dataRadarData[]
The series to draw, one polygon each. Every item holds a values record keyed by metric key; the series index is what RadarArea refers to with index.
metricsRadarMetric[]
The metrics, one spoke each, in clockwise order from 12 o'clock. A metric's key selects its value in every series' values, and its label is what RadarLabels prints.
size?number
Chart width and height in pixels. Omit to fill the width of the parent element; the chart stays square.
levels?number
Number of concentric grid rings drawn by RadarGrid. Ring n marks n / levels of the 0 to 100 value scale.
- Default
5
margin?number
Space in pixels kept free around the chart for the metric labels.
- Default
60
animate?boolean
Play the entrance animation. Set false to draw the chart immediately.
- Default
true
enterDurationMs?number
Total time budget of the entrance animation in milliseconds. Grid, labels and series timings scale with it.
- Default
1100
staggerScale?number
Multiplier for the delays between grid rings, labels and series during the entrance. 0 starts everything together.
- Default
1
enterTransition?RadarEnterTransition
Transition for the series entrance, in the shape used by the motion library (type: "spring" with spring values, or a tween with duration in seconds and ease). Defaults to a 1.1 second tween on the shared reveal curve.
motionReplayKey?string
Changing this string replays the entrance animation.
- Default
""
hoveredIndex?number | null
Index of the hovered series, for controlled hover. Pass null for no hover; leave it undefined to let the chart manage hover itself.
- Type
number | null
onHoverChange?(index: number | null) => void
Called with the index of the hovered or keyboard-focused series, or null when hover ends.
- Type
(index: number | null) => void
className?string
Extra class name for the chart container.
style?CSSProperties
Inline styles for the chart container, merged over the default sizing.
childrenReactNode
The parts to draw: RadarGrid, RadarAxis, RadarLabels and one RadarArea per series. Only the parts you include are drawn.
ariaLabel?string
Accessible name of the chart.
- Default
"Radar chart"
ariaDescription?string
Longer accessible description of the chart.
RadarGrid
showLabels?boolean
Print the value of each grid ring along the first spoke.
- Default
true
stroke?string
Colour of the grid lines.
- Default
"var(--bkm-border)"
strokeOpacity?number
Opacity of the grid lines, from 0 to 1.
- Default
0.6
className?string
Extra class name for the grid lines.
RadarAxis
stroke?string
Colour of the axis lines.
- Default
"var(--bkm-border)"
strokeOpacity?number
Opacity of the axis lines, from 0 to 1.
- Default
0.6
className?string
Extra class name for the axis lines.
RadarLabels
offset?number
Distance in pixels between the outer grid ring and the labels.
- Default
24
fontSize?number
Font size of the labels in pixels.
- Default
11
interactive?boolean
Dim the labels at rest and brighten them while a series is hovered.
- Default
false
className?string
Extra class name for the labels.
RadarArea
indexnumber
Index of the series this element draws, matching its position in the data array of the chart. Entries with an index outside the array are ignored.
color?string
Colour of the series. Takes precedence over the data item's color, which in turn takes precedence over the --chart-1 to --chart-5 palette (by index).
showPoints?boolean
Draw a dot at each metric value.
- Default
true
showStroke?boolean
Draw an outline around the polygon.
- Default
true
showGlow?boolean
Draw a glow behind the polygon while the series is hovered: a 12 px drop shadow in the series colour.
- Default
false
className?string
Extra class name for the polygon.
Examples
9 examples on React, each live with its code and its own install command.
- Radar ChartRadar chart

- Radar Chart with Controlled HoverRadar chart

- Minimal Radar ChartRadar chart

- Radar Chart with LegendRadar chart

- Triangle Radar ChartRadar chart

- Radar Chart with Fills OnlyRadar chart

Related chart types
Charts close to the radar chart: the same data drawn another way, or the type to reach for when this one stops fitting.





