shadcn.io is not affiliated with official shadcn/ui
About
Use it when each series is a kind of thing with an obvious symbol: an activity, a device, a channel. The icon sits where the dot would, next to the series name and its value, and the date heading is hidden to keep the tooltip short.
The icons live in chartConfig, not in the tooltip, so a legend on the same chart picks them up too.
Installation
Usage
import { ChartTooltipIcons } from "@/components/charts/chart-tooltip-icons";<ChartTooltipIcons />Customize
icon: Footprintsandicon: WavesinchartConfigdo the work;ChartTooltipContentrenders them in place of the dot.<ChartTooltip content={<ChartTooltipContent hideLabel />} />drops the date heading.- Icons are styled by the row's
[&>svg]:size-2.5 [&>svg]:text-muted-foregroundclasses. - Import the icons from
lucide-react; any component that renders an<svg>works.
FAQ
Where do the icons come from?
From chartConfig: running: { icon: Footprints, … }. When an entry has an icon, ChartTooltipContent renders it in place of the indicator.
Can I use other icons?
Any React component works as icon: another Lucide icon or your own SVG. The row sizes it to size-2.5 and colors it text-muted-foreground through [&>svg]: classes.
Do the icons show in a legend too?
Yes. ChartLegendContent reads the same icon from chartConfig; pass hideIcon to keep the color swatches instead.
API Reference
ChartContainer
configChartConfig
Each series by its data key: its label, an icon, and a color (or a * theme color per light and dark), read by the tooltip and legend and set * as --color-<key>.
initialDimension?{ height: number; width: number; }
The size it renders at before it's measured, so the first paint isn't * empty.
- Type
{ height: number; width: number; }- Default
INITIAL_DIMENSION
className?string
Merged with the part's classes.
ChartLegend
ChartLegendContent
<div>
hideIcon?boolean
Hides each series' icon (from config), leaving its color swatch.
- Default
false
nameKey?string
The key in each legend item's data to look its label up by in config. * Defaults to the item's dataKey.
className?string
Merged with the part's classes.
ChartStyle
<style>
configChartConfig
The chart config whose colors it writes as --color-<key> variables.
idstring
The element's id.
ChartTooltip
ChartTooltipContent
<div>
hideIndicator?boolean
Hides each item's color indicator.
- Default
false
hideLabel?boolean
Hides the tooltip's label, the hovered point's.
- Default
false
indicator?"dashed" | "dot" | "line"
The color indicator's shape: a dot, a line or dashed.
- Type
"dashed" | "dot" | "line"- Default
"dot"
labelFormatter?(label: any, payload: TooltipPayload) → React.ReactNode
Formats the tooltip's label; its value is untyped, as in recharts 3.8.
- Type
(label: any, payload: TooltipPayload) → React.ReactNode- Parameters
label– anypayload– TooltipPayload- Returns
React.ReactNode
labelKey?string
The key in the data to read the label from, looked up in config.
nameKey?string
The key in each item's data to look its name up by in config.
className?string
Merged with the part's classes.
Related
Area Chart with Icons
Area chartsStacked areas with an icon beside each series in the legend.
Radar Chart with Icons
Radar chartsTwo radar series with icons in their legend.
Chart Tooltip with Formatter
TooltipsA tooltip whose values carry their own units.
Chart Tooltip without Indicator
TooltipsA tooltip with no color indicator beside the series.
Chart Tooltip
TooltipsThe default tooltip: a label, then each series with its dot.
A tooltip that marks each series with a line, not a dot.