Tooltips and legends make your charts interactive and easier to understand. This guide covers configuration and customization.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/recharts/recharts/llms.txt
Use this file to discover all available pages before exploring further.
Tooltip basics
TheTooltip component displays data values when users hover over or click chart elements.
Default tooltip
Add a tooltip with default styling:Tooltip trigger modes
Control when tooltips appear using thetrigger prop:
https://github.com/recharts/recharts/blob/main/src/component/Tooltip.tsx:230-235
Shared vs individual tooltips
Theshared prop controls whether the tooltip shows data for all series or just one:
https://github.com/recharts/recharts/blob/main/src/component/Tooltip.tsx:216-227
Tooltip customization
Styling the tooltip
Customize appearance using style props:contentStyle: Styles the tooltip containeritemStyle: Styles each data item (<li>element)labelStyle: Styles the label (<p>element)wrapperStyle: Styles the outer wrapper div
https://github.com/recharts/recharts/blob/main/src/component/Tooltip.tsx:120-243
Custom separator
Change the separator between name and value:" : ".
Formatting values
Use theformatter prop to customize how values display:
value: The data valuename: The series nameitem: The complete tooltip payload entryindex: The item indexpayload: All tooltip data
https://github.com/recharts/recharts/blob/main/src/component/Tooltip.tsx:139-148
Formatting labels
Customize the tooltip label (typically the x-axis value):https://github.com/recharts/recharts/blob/main/src/component/Tooltip.tsx:174-177
Custom tooltip content
Create a completely custom tooltip:active: Whether tooltip is activepayload: Array of data for all visible serieslabel: The axis labelcoordinate: Mouse positionaccessibilityLayer: Accessibility settings
https://github.com/recharts/recharts/blob/main/src/component/Tooltip.tsx:108-119
Tooltip positioning
Offset
Control distance from cursor:10.
Source: https://github.com/recharts/recharts/blob/main/src/component/Tooltip.tsx:184-190
Fixed position
Lock tooltip to a specific position:https://github.com/recharts/recharts/blob/main/src/component/Tooltip.tsx:200-206
Allow escape viewbox
Let tooltip extend beyond chart boundaries:{ x: false, y: false }.
Source: https://github.com/recharts/recharts/blob/main/src/component/Tooltip.tsx:80-85
Advanced tooltip features
Filter null values
Hide entries with null values:https://github.com/recharts/recharts/blob/main/src/component/Tooltip.tsx:134-137
Include hidden series
Show data from hidden series:https://github.com/recharts/recharts/blob/main/src/component/Tooltip.tsx:150-156
Portal rendering
Render tooltip outside the chart container to avoid clipping:https://github.com/recharts/recharts/blob/main/src/component/Tooltip.tsx:192-198
Cursor customization
Customize or disable the cursor shown on hover:https://github.com/recharts/recharts/blob/main/src/component/Tooltip.tsx:126-131
Legend basics
TheLegend component shows labels for each data series.
Default legend
Legend alignment
Control vertical and horizontal positioning:verticalAlign:"top","middle","bottom"align:"left","center","right"
https://github.com/recharts/recharts/blob/main/src/component/Legend.tsx:147-156
Legend layout
Control how legend items are arranged:https://github.com/recharts/recharts/blob/main/src/component/DefaultLegendContent.tsx
Legend customization
Styling
Customize legend appearance:https://github.com/recharts/recharts/blob/main/src/component/Legend.tsx:111-114
Custom content
Create a custom legend:https://github.com/recharts/recharts/blob/main/src/component/Legend.tsx:98-110
Sorting legend items
Control the order of legend items:https://github.com/recharts/recharts/blob/main/src/component/Legend.tsx:136-145
Best practices
Tooltip animationsBy default, tooltips respect the user’s
prefers-reduced-motion setting. Set isAnimationActive={false} to disable animations completely.