Skip to main content
Legend
@coinbase/cds-web-visualization@3.4.0-beta.14
A legend component for displaying series information in charts. Supports customizable shapes, layouts, and custom item components.
import { Legend } from '@coinbase/cds-web-visualization'
Peer dependencies
  • framer-motion: ^10.18.0
Related components

Legend displays series information for charts, showing labels and color indicators for each data series. It can be positioned around the chart and supports custom shapes and item components.

Basics

Use the legend prop on chart components to enable a default legend, or pass a Legend component for customization. Legend's flexDirection is automatically set to row for top/bottom legendPosition and column otherwise.

Loading...

Legend will automatically wrap when there are too many items to fit on one line.

Loading...

Position

Use legendPosition to place the legend at different positions around the chart. You can also customize alignment using the justifyContent prop on Legend.

Loading...

Shape Variants

Legend supports different shape variants: pill, circle, square, and squircle. Set the shape on each series using legendShape.

Loading...

Styling

Custom Shape

You can pass a custom ReactNode as legendShape for fully custom indicators.

Loading...

Accessibility

Use legendAccessibilityLabel on chart components to provide a descriptive label for the legend group. This helps screen reader users understand what the legend represents.

Loading...

You can also set accessibilityLabel directly on the Legend component for more control:

Loading...

Composed Examples

Dynamic Label

You can use EntryComponent to display a label that updates as a user interacts with the chart.

Loading...

Interactive Legend

You can create an interactive legend that the user can use to toggle to emphasize a specific series.

Loading...

Is this page useful?

Coinbase Design is an open-source, adaptable system of guidelines, components, and tools that aid the best practices of user interface design for crypto products.