Pie chart components

FREE

Powerful and customizable React pie chart components built for modern applications and websites. These pie charts are built using Recharts and styled with Tailwind CSS.

Installation

You can add this charts component using our CLI or manually:

npx untitledui@latest add charts-base

Pie chart examples

Below are examples and variations of this pie chart component:

API reference

ChartLegendContent

Renders the legend content for a chart.

Import ChartLegendContent from @/components/application/charts/charts-base. Renders a <ul> element.

ChartLegendContent props
PropTypeDefaultDescription
reversedboolean—Whether the legend entries are listed in the reverse of the order Recharts supplies them, so a stacked chart's legend reads in the same order as its stack.
classNamestring—Additional classes for the legend list, merged after the layout and alignment classes derived from the Recharts Legend props.
Props from recharts (170)
ChartLegendContent inherited props
PropTypeDefaultDescription
align
"center""left""right"
centerDeprecated.—
childrenReactNode——
formatterFormatter—Function to customize how content is serialized before rendering.This should return HTML elements, or strings.
iconSizenumber14The size of icon in each legend item.
iconType
"none""square""circle""triangle""cross""diamond""line""plainline""rect""star""wye"
—The type of icon in each legend item.
inactiveColorstring#cccThe color of the icon when the item is inactive.
labelStyleCSSProperties{ }Style of individual items inside the Legend, a <span> element. These show the data label (name, or dataKey) and value.If a chart has multiple graphical items then the Legend renders multiple item and each of them gets this itemStyle applied.Pie charts render multiple labels from a single data series.Note that this is different from Tooltip:
  • in Tooltip: "labelStyle" styles the title / header.
  • in Tooltip: "itemStyle" styles the individual data points.
  • in Legend: "labelStyle" styles the individual data points.
Beware of the naming inconsistency!
layout
"horizontal""vertical"
horizontalThe layout of legend items inside the legend container.
onClick((data: LegendPayload, index: number, event: MouseEvent<HTMLElement>) => void)—The customized event handler of click on the items in this group.
payloadreadonly LegendPayload[]—DefaultLegendContent.payload is omitted from Legend props. A custom payload can be passed here if desired, or it can be passed from the Legend "content" callback.
verticalAlign
"middle""bottom""top"
middleDeprecated.—
onAbortAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onAbortCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onAnimationEndAdaptChildAnimationEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onAnimationEndCaptureAdaptChildAnimationEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onAnimationIterationAdaptChildAnimationEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onAnimationIterationCaptureAdaptChildAnimationEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onAnimationStartAdaptChildAnimationEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onAnimationStartCaptureAdaptChildAnimationEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onAuxClickAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onAuxClickCaptureAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onBeforeInputAdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onBeforeInputCaptureAdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onBlurAdaptChildFocusEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onBlurCaptureAdaptChildFocusEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onCanPlayAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onCanPlayCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onCanPlayThroughAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onCanPlayThroughCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onChangeAdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onChangeCaptureAdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onClickCaptureAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onCompositionEndAdaptChildCompositionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onCompositionEndCaptureAdaptChildCompositionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onCompositionStartAdaptChildCompositionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onCompositionStartCaptureAdaptChildCompositionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onCompositionUpdateAdaptChildCompositionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onCompositionUpdateCaptureAdaptChildCompositionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onContextMenuAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onContextMenuCaptureAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onCopyAdaptChildClipboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onCopyCaptureAdaptChildClipboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onCutAdaptChildClipboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onCutCaptureAdaptChildClipboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDoubleClickAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDoubleClickCaptureAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDragAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDragCaptureAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDragEndAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDragEndCaptureAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDragEnterAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDragEnterCaptureAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDragExitAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDragExitCaptureAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDragLeaveAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDragLeaveCaptureAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDragOverAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDragOverCaptureAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDragStartAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDragStartCaptureAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDropAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDropCaptureAdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDurationChangeAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onDurationChangeCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onEmptiedAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onEmptiedCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onEncryptedAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onEncryptedCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onEndedAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onEndedCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onErrorAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onErrorCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onFocusAdaptChildFocusEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onFocusCaptureAdaptChildFocusEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onGotPointerCaptureAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onGotPointerCaptureCaptureAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onInputAdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onInputCaptureAdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onInvalidAdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onInvalidCaptureAdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onKeyDownAdaptChildKeyboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onKeyDownCaptureAdaptChildKeyboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onKeyPressAdaptChildKeyboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onKeyPressCaptureAdaptChildKeyboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onKeyUpAdaptChildKeyboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onKeyUpCaptureAdaptChildKeyboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onLoadAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onLoadCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onLoadedDataAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onLoadedDataCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onLoadedMetadataAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onLoadedMetadataCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onLoadStartAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onLoadStartCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onLostPointerCaptureAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onLostPointerCaptureCaptureAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onMouseDownAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onMouseDownCaptureAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onMouseEnter((data: LegendPayload, index: number, event: MouseEvent<HTMLElement>) => void)—The customized event handler of mouseenter on the items in this group.
onMouseLeave((data: LegendPayload, index: number, event: MouseEvent<HTMLElement>) => void)—The customized event handler of mouseleave on the items in this group.
onMouseMoveAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onMouseMoveCaptureAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onMouseOutAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onMouseOutCaptureAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onMouseOverAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onMouseOverCaptureAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onMouseUpAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onMouseUpCaptureAdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPasteAdaptChildClipboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPasteCaptureAdaptChildClipboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPauseAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPauseCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPlayAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPlayCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPlayingAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPlayingCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerCancelAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerCancelCaptureAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerDownAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerDownCaptureAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerEnterAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerEnterCaptureAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerLeaveAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerLeaveCaptureAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerMoveAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerMoveCaptureAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerOutAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerOutCaptureAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerOverAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerOverCaptureAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerUpAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onPointerUpCaptureAdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onProgressAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onProgressCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onRateChangeAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onRateChangeCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onResetAdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onResetCaptureAdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onScrollAdaptChildUIEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onScrollCaptureAdaptChildUIEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onSeekedAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onSeekedCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onSeekingAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onSeekingCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onSelectAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onSelectCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onStalledAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onStalledCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onSubmitAdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onSubmitCaptureAdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onSuspendAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onSuspendCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onTimeUpdateAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onTimeUpdateCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onTouchCancelAdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onTouchCancelCaptureAdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onTouchEndAdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onTouchEndCaptureAdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onTouchMoveAdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onTouchMoveCaptureAdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onTouchStartAdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onTouchStartCaptureAdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onTransitionEndAdaptChildTransitionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onTransitionEndCaptureAdaptChildTransitionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onVolumeChangeAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onVolumeChangeCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onWaitingAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onWaitingCaptureAdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onWheelAdaptChildWheelEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——
onWheelCaptureAdaptChildWheelEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>>——

Also accepts all aria-* attributes.

ChartTooltipContent

Import ChartTooltipContent from @/components/application/charts/charts-base. Renders a <div> element.

ChartTooltipContent props
PropTypeDefaultDescription
isRadialChartboolean—Whether the tooltip belongs to a Recharts RadialBarChart. When a single point is hovered, the supporting line is read from payload[0].payload.name instead of the axis label.
isPieChartboolean—Whether the tooltip belongs to a Recharts PieChart. When a single slice is hovered, the supporting line is the slice's name instead of the axis label.
labelstring—The category label Recharts passes for the hovered position. Used as the tooltip heading when several series are active, and as the supporting line otherwise.
payloadany—The active data points Recharts passes to the Tooltip content. Each entry supplies the series name and value rendered as a row in the tooltip.
Props from recharts (29)
ChartTooltipContent inherited props
PropTypeDefaultDescription
activeboolean—If true, then Tooltip is always displayed, once an activeIndex is set by mouse over, or programmatically. If false, then Tooltip is never displayed. If undefined, Recharts will control when the Tooltip displays. This includes mouse and keyboard controls.
allowEscapeViewBoxAllowInDimension{ x: false, y: false }This option allows the tooltip to extend beyond the viewBox of the chart itself.
animationDurationnumber400Specifies the duration of animation, the unit of this option is ms.
animationEasingEasingInputeaseThe type of easing function.
axisIdAxisId0Tooltip always attaches itself to the "Tooltip" axis. Which axis is it?Depends on the layout:
  • horizontal layout -> X axis.
  • vertical layout -> Y axis.
  • radial layout -> radial axis.
  • centric layout -> angle axis.
Tooltip will use the default axis for the layout, unless you specify an axisId.
contentContentType<ValueType, NameType>—Renders the content of the tooltip.This should return HTML elements, not SVG elements.
  • If not set, the DefaultTooltipContent component is used.
  • If set to a React element, this element will be cloned and extra props will be passed in.
  • If set to a function, the function will be called and should return HTML elements.
contentStyleCSSProperties——
cursorCursorDefinitiontrueIf set false, no cursor will be drawn when tooltip is active. If set a object, the option is the configuration of cursor. If set a React element, the option is the custom react element of drawing cursor.
defaultIndexnumber | TooltipIndex——
filterNullbooleantrueWhen an item of the payload has value null or undefined, this item won't be displayed.
formatterFormatter<TValue, TName>——
includeHiddenbooleanfalseIf true, the tooltip will display information about hidden series. Defaults to false. Interacting with the hide property of Area, Bar, Line, Scatter.
isAnimationActive
falsetrue"auto"
autoIf set false, animation of tooltip will be disabled. If set "auto", the animation will be disabled in SSR and will respect the user's prefers-reduced-motion system preference for accessibility.
itemSorter(TooltipItemSorter<ValueType, NameType> & TooltipItemSorter)——
itemStyleCSSProperties——
labelClassNamestring——
labelFormatter(label: ReactNode, payload: ReadonlyArray<Payload<TValue, TName>>) => ReactNode——
labelStyleCSSProperties——
offsetnumber | Coordinate10The offset size between the position of tooltip and the mouse cursor position. When a number is provided, the same offset is applied to both x and y axes.When a Coordinate object is provided, you can specify different offsets for each axis (x and y as numbers).
payloadUniqByUniqueOption<TooltipPayloadEntry>——
portalHTMLElement | null—If portal is defined, then Tooltip will use this element as a target for rendering using React Portal: https://react.dev/reference/react-dom/createPortal.If this is undefined then Tooltip renders inside the recharts-wrapper element.
positionPartial<Coordinate>—If this field is set, the tooltip will be displayed at the specified position regardless of the mouse position.You can set a single field (x or y) and let the other field be calculated automatically based on the mouse position.
reverseDirectionAllowInDimension{ x: false, y: false }—
separatorstring——
sharedboolean—Defines whether the tooltip is reacting to the current data point, or to all data points at the current axis coordinate.
  • true: tooltip will appear on top of all bars on an axis tick.
  • false: tooltip will appear on individual bars.
Different chart types allow different modes, and have different defaults.
trigger
"hover""click"
hoverIf hover then the Tooltip shows on mouse enter and hides on mouse leave.If click then the Tooltip shows after clicking and stays active.
useTranslate3dbooleanfalse—
wrapperClassNamestring——
wrapperStyleCSSProperties—CSS styles to be applied to the wrapper div element.

FAQs

Please refer to our frequently asked questions page for more.

Pass a data array of { name: string; value: number; className?: string }. The Recharts <Pie> reads dataKey="value" for the slice size and nameKey="name" for the label shown in the legend and tooltip. The optional className sets the slice color, as described below.

Set a text color class on each data entry via className, such as text-utility-brand-600 or text-utility-neutral-200, because the <Pie> is rendered with fill="currentColor". The same className is picked up by ChartLegendContent, which paints the legend swatch with bg-current, so the legend and the chart stay in sync automatically.

The pie charts are copy-paste examples rather than exported components: what you install is charts-base.tsx, and the five sizes on this page live in pie-charts.demo.tsx. PieChartXxs, PieChartXs, PieChartSm, PieChartMd and PieChartLg differ only in the ResponsiveContainer height (120, 160, 200, 240 and 280), its max-w-* class, and the innerRadius/outerRadius pair on the <Pie> (30/60, 40/80, 50/100, 60/120 and 70/140). Copy the closest one and adjust those numbers for any size in between.

Set innerRadius={0} on the <Pie>. The examples ship as donuts because innerRadius is half of outerRadius; the hole is purely that prop, so there is nothing else to change.

The chart passes <Tooltip content={<ChartTooltipContent isPieChart />} />, where ChartTooltipContent comes from charts-base.tsx. Whenever a single data point is hovered its value becomes the tooltip title, with or without the flag — isPieChart only changes where the supporting line underneath is read from, using the hovered slice's name instead of the axis label. It also accepts Recharts' formatter and labelFormatter, so pass those through the <Tooltip> to format currency or percentages.

Yes. The legend is a standard Recharts <Legend> rendered with content={ChartLegendContent}, so placement props go on the <Legend> itself — the examples use verticalAlign="top" align="right" layout="vertical". Recharts passes them down, and ChartLegendContent reads layout to switch between a stacked column and an inline row, then align to justify the items within it. It also accepts reversed to flip the item order and a className.

Each chart is wrapped in a Recharts ResponsiveContainer with a fixed height and initialDimension={{ width: 1, height: 1 }}, so it fills the width of its parent — the examples cap that with a class such as max-w-96. Animation is off by default because the <Pie> sets isAnimationActive={false}; remove that prop to re-enable Recharts' entry animation.