Line chart
A multi-series line chart with a gliding crosshair, legend toggles, and paths that morph between ranges.
A donut whose arcs morph between datasets, with the active value rolling into the center.
npx shadcn@latest add @silicon-ui/donut-chartnpx shadcn@latest add @silicon-ui/donut-chartInstall the dependencies.
npm install motionCopy these files into your project. Shared files are skipped if you already have them.
components/silicon-ui/donut-chart/donut-chart.tsxcomponents/silicon-ui/donut-chart/donut-chart.module.cssInstall the foundation once per app for the design and motion tokens: npx shadcn@latest add @silicon-ui/silicon-foundation
| Prop | Type | Default |
|---|---|---|
data* | DonutChartDatum[] | — |
label*What the whole is, such as "Visits by source". Names the chart for assistive technology. | string | — |
unitUnit after values, such as "visits". | string | "" |
formatValue | (value: number) => string | value => grouped.format(value) |
totalLabelCenter label at rest, above the total. | string | "Total" |
sizeDiameter in pixels. The chart scales down to fit narrower containers. | number | 208 |
thicknessRing thickness in pixels. | number | 24 |
groupBelowSegments below this share of the total join "Other". | number | .04 |
maxSegmentsThe most segments drawn, counting "Other". The smallest parts beyond it are grouped. | number | 6 |
otherLabel | string | "Other" |
activeKeyControlled selected segment key. Hover and focus preview other segments without changing it. | string | null | — |
defaultActiveKey | string | null | null |
onActiveChange | (key: string | null) => void | — |
hiddenKeysControlled hidden segment keys. A hidden segment closes and the rest of the ring redistributes. | string[] | — |
defaultHiddenKeys | string[] | — |
onHiddenKeysChange | (keys: string[]) => void | — |
legendActionWhat clicking a legend row does: show or hide its segment, or pin it as the selected segment. | "toggle" | "select" | "toggle" |
legendThe synced legend beside or below the ring. | boolean | true |
emptyLabel | string | "No data yet" |
ref | Ref<HTMLElement> | — |
className | string | — |