Prodular UI

Legend

The key to a chart, map, graph or timeline: colors, shapes and line styles with labels, grouping and optional toggles.

npx prodular-ui add legend

Series and encodings

Toggle series on a chart, and a grouped key for severity shapes and link styles.

SeverityCriticalHighElevatedRoutine
LinksConfirmedSuspectedHistorical

Anatomy

<Legend aria-label="Payment methods">  <LegendItem color="chart-1" shape="line" label="Card" active={on} onActiveChange={setOn} /></Legend>

Guidance

Use it when

  • Any visual where color, shape or line style carries meaning.
  • onActiveChange to let people hide a series.
  • LegendGroup when one visual has more than one encoding.

Avoid

  • Color as the only difference between items. Give each a shape or line style too.
  • Legends for a single series. Label it in the title.

Rules for AI agents

Published in llms-full.txt, the registry and the MCP server, so coding agents follow them when they build with this component.

  • Use the same color token and shape as the visual draws, for example color="severity-high" with shape="triangle".
  • Give Legend an aria-label when there is more than one on screen.
  • Toggles need onActiveChange and active; they render as buttons with aria-pressed.

API

Legend

PropTypeDefaultDescription
orientation"horizontal" | "vertical""horizontal"Wraps in a row, or stacks.

LegendItem

PropTypeDefaultDescription
colorstringA token name ("chart-1", "severity-high") or a CSS color.
shape"circle" | "square" | "diamond" | "triangle" | "line" | "dashed" | "dotted""circle"The mark.
activebooleantrueInactive items dim and strike through.
onActiveChange(active: boolean) => voidMakes the item a toggle.

Installation

The Prodular UI CLI adds the source to components/ui with everything it depends on. In a project that already uses shadcn/ui, the shadcn CLI installs it from the Prodular registry too. See Installation for the first setup.

npx prodular-ui add legend# or, with the registry in components.jsonnpx shadcn@latest add @prodular/legend