Usage
Props
Content
ReactElement | function
Renders the content of the tooltip.This should return HTML elements, not SVG elements.Options:
- Not set: Uses DefaultTooltipContent component
ReactElement: Element is cloned with extra propsfunction: Called to render HTML elements
Behavior
'hover' | 'click'
default:"hover"
Controls when the tooltip appears.
hover: Shows on mouse enter, hides on mouse leaveclick: Shows after clicking, stays active
Defines whether the tooltip reacts to the current data point or all data points at the current axis coordinate.
true: Tooltip appears on top of all items at an axis tickfalse: Tooltip appears on individual items
boolean
Controls tooltip visibility.
true: Tooltip is always displayed once an activeIndex is setfalse: Tooltip is never displayedundefined: Recharts controls when tooltip displays
Position
Partial<Coordinate>
If set, the tooltip displays at the specified position regardless of mouse position.You can set a single field (x or y) and let the other be calculated automatically.
number | Coordinate
default:"10"
The offset between the tooltip and the mouse cursor position.
- Number: Same offset for both x and y axes
- Coordinate: Different offsets for each axis
AllowInDimension
default:"{x: false, y: false}"
Allows the tooltip to extend beyond the viewBox of the chart.
AllowInDimension
default:"{x: false, y: false}"
Reverses the direction the tooltip appears relative to the cursor.
Styling
CSSProperties
default:"{}"
CSS styles applied to the wrapper
div element.CSSProperties
default:"{}"
CSS styles applied to the tooltip content element.
CSSProperties
default:"{}"
CSS styles applied to each tooltip item (li element).
CSSProperties
default:"{}"
CSS styles applied to the tooltip label (p element).
Cursor
boolean | object | ReactElement | function
default:"true"
Controls the cursor element shown when tooltip is active.Options:
false: No cursortrue: Default cursorobject: Props for cursor elementReactElement: Custom cursor elementfunction: Render function for custom cursor
Data formatting
function
Customizes the value in the tooltip.Signature:
(value, name, item, index, payload) => ReactNode | [ReactNode, ReactNode]If you return an array, the first entry is the formatted value, the second is the formatted name.function
Formats the tooltip label.Signature:
(label: any, payload: TooltipPayload) => ReactNodestring
default:" : "
The separator between name and value.
Filtering
boolean
default:"true"
When true, items with null or undefined values are not displayed.
If true, the tooltip displays information about hidden series.
UniqueOption
Function to determine uniqueness of tooltip items.
TooltipItemSorter
default:"name"
Sorts tooltip items.Default sorts alphabetically by graphical item
name property.Animation
boolean | 'auto'
default:"auto"
If false, animation is disabled.If “auto”, animation is disabled in SSR and respects the user’s prefers-reduced-motion preference.
number
default:"400"
Duration of animation, in milliseconds.
string
default:"ease"
The type of easing function.Options: ‘ease’, ‘ease-in’, ‘ease-out’, ‘ease-in-out’, ‘linear’
Portal
HTMLElement | null
If defined, Tooltip uses this element as a target for rendering using React Portal.If undefined, Tooltip renders inside the recharts-wrapper element.
Advanced
string | number
default:"0"
The tooltip attaches to the “Tooltip axis” which depends on layout.Use this to specify which axis the tooltip uses.
number | string
Default active index for the tooltip.
boolean
default:"false"
If true, uses CSS translate3d for positioning.
Other
string | number
The label displayed in the tooltip.Automatically provided by chart context.
TooltipPayload
The array of data items to display.Automatically provided by chart context.
Coordinate
The coordinate where the tooltip should appear.Automatically provided by chart context.