Docs/General Components/Tooltip

Tooltip

Tooltip displays a floating box with the values from the active data point. It appears on hover (by default), keyboard navigation, or on click depending on the trigger prop.

import { LineChart, Line, XAxis, YAxis, Tooltip } from "solid-recharts";

<LineChart data={data}>
  <XAxis dataKey="name" />
  <YAxis />
  <Tooltip />
  <Line dataKey="uv" stroke="#8884d8" />
</LineChart>;
Tooltip
tooltip-custom.tsxOpen ↗
Loading source...

Props

PropTypeDefaultDescription
contentJSX.Element | (props) => JSX.Element—Custom component to render tooltip content; receives TooltipContentProps
formatter(value, name) => string | [str, str]—Format each payload entry's value
labelFormatter(label) => string—Format the tooltip label (categorical axis name)
itemSorterstring | (a, b) => number"name"Sort payload entries by "name", "value", or custom function
filterNullbooleantrueHide entries with null or undefined values
cursorboolean | CursorDefinitiontrueShow a highlight line/shape at the active point
sharedbooleantrueShow all series' values at once (false = active series only)
trigger"hover" | "click""hover"Activation mode
defaultIndexnumber—Initial active point before user interaction
offsetnumber | { x, y }10Distance from the trigger point to the tooltip box
position{ x, y }—Fixed position (overrides automatic positioning)
wrapperStyleJSX.CSSProperties{}Styles for the tooltip wrapper div

Notes

  • content is called with TooltipContentProps (label, payload array, coordinate, active, etc.). Define it as a function: content={(props) => <CustomTooltip {...props} />}.
  • payload is an array of entries (one per series); each entry has value, name, dataKey, fill/stroke.
  • itemSorter accepts "name" (alphabetical), "value" (by numeric value), or a comparator function (a, b) => -1|0|1.
  • filterNull applies after itemSorter; set to false to show all entries.
  • shared={true} (default) shows all series at one tooltip; shared={false} shows only the active series.
  • trigger="click" requires mouse/touch events to toggle the tooltip on/off.

See also

  • Legend — legend entries can sync with tooltip via onClick
  • LineChart — primary chart using tooltips
  • Composed Chart — multiple series with shared tooltip