Skip to main content
Recharts is highly customizable. You can create custom components to extend functionality or achieve unique designs.

Custom components in Recharts 3

The Customized wrapper is deprecatedStarting from Recharts 3.x, you can render custom components directly without the Customized wrapper. The wrapper will be removed in version 4.0.

Render custom components directly

In Recharts 3.x and later, add custom elements anywhere in your chart:
Source: https://github.com/recharts/recharts/blob/main/src/component/Customized.tsx:22-28

Custom shapes

Custom dots on lines

Replace default dots with custom shapes:
Dot component receives:
  • cx, cy: Center coordinates
  • r: Radius
  • fill, stroke: Colors
  • value: Data value
  • payload: Complete data point
  • index: Point index

Custom bar shapes

Create custom shapes for bars:

Custom labels

Custom axis tick labels

Create custom tick components:

Custom label list

Add labels to data points:

Custom tooltips

See the Tooltips and legends guide for detailed tooltip customization.

Custom legends

See the Tooltips and legends guide for detailed legend customization.

Accessing chart context

Custom components can access chart data and layout using hooks.

Access chart dimensions

Custom annotations

Threshold line

Draw a horizontal line at a specific value:

Reference area

Highlight a specific range:

Custom active shapes

Animated active dot

Custom active bar

SVG patterns and gradients

Gradient fills

Pattern fills

Custom chart backgrounds

Interactive custom components

Clickable annotations

Best practices

Use SVG primitivesCustom components should return SVG elements (<g>, <rect>, <circle>, <text>, etc.), not HTML elements.
Avoid complex calculations in renderIf your custom component does heavy calculations, memoize the results:
Coordinate systemsRemember that SVG coordinates start at the top-left (0, 0). Positive Y goes down, not up.

Migration from Recharts 2

If upgrading from Recharts 2.x:
Source: https://github.com/recharts/recharts/blob/main/src/component/Customized.tsx:23-27