Chart Legend

Wrapping chart legend with small color swatches and labels. Pass colors per series or fall back to accent, success, warning and danger theme tokens.

src/registry/ui/chart-legend.tsx/r/chart-legend.json

Installation#

bash
npx shadcn@latest add @minidev/chart-legend

MiniDev UI is in the shadcn registry directory, so the short form works with no setup. Older CLI versions can use the full URL: npx shadcn@latest add https://ui.minidev.pro/r/chart-legend.json

Usage#

tsx
import { ChartLegend } from "@/components/ui/chart-legend"

export function Example() {
  return (
    <ChartLegend items={[{ label: "Free" }, { label: "Premium" }, { label: "Studio" }]} />
  )
}

API reference#

ChartLegend props
PropTypeDefault
itemsLegendItem[]SAMPLE_ITEMS
classNamestring-

Examples#

All chart components

Learn more