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
Import ChartLegendContent from @/components/application/charts/charts-base. Renders a <ul> element.
| Prop | Type | Default | Description |
|---|---|---|---|
reversed | boolean | — | 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. |
className | string | — | Additional classes for the legend list, merged after the layout and alignment classes derived from the Recharts Legend props. |
Props from recharts (170)
| Prop | Type | Default | Description |
|---|---|---|---|
align | "center""left""right" | center | Deprecated.— |
children | ReactNode | — | — |
formatter | Formatter | — | Function to customize how content is serialized before rendering.This should return HTML elements, or strings. |
iconSize | number | 14 | The 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. |
inactiveColor | string | #ccc | The color of the icon when the item is inactive. |
labelStyle | CSSProperties | { } | 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:
|
layout | "horizontal""vertical" | horizontal | The 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. |
payload | readonly 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" | middle | Deprecated.— |
onAbort | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onAbortCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onAnimationEnd | AdaptChildAnimationEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onAnimationEndCapture | AdaptChildAnimationEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onAnimationIteration | AdaptChildAnimationEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onAnimationIterationCapture | AdaptChildAnimationEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onAnimationStart | AdaptChildAnimationEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onAnimationStartCapture | AdaptChildAnimationEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onAuxClick | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onAuxClickCapture | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onBeforeInput | AdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onBeforeInputCapture | AdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onBlur | AdaptChildFocusEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onBlurCapture | AdaptChildFocusEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onCanPlay | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onCanPlayCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onCanPlayThrough | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onCanPlayThroughCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onChange | AdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onChangeCapture | AdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onClickCapture | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onCompositionEnd | AdaptChildCompositionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onCompositionEndCapture | AdaptChildCompositionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onCompositionStart | AdaptChildCompositionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onCompositionStartCapture | AdaptChildCompositionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onCompositionUpdate | AdaptChildCompositionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onCompositionUpdateCapture | AdaptChildCompositionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onContextMenu | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onContextMenuCapture | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onCopy | AdaptChildClipboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onCopyCapture | AdaptChildClipboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onCut | AdaptChildClipboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onCutCapture | AdaptChildClipboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDoubleClick | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDoubleClickCapture | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDrag | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDragCapture | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDragEnd | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDragEndCapture | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDragEnter | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDragEnterCapture | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDragExit | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDragExitCapture | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDragLeave | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDragLeaveCapture | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDragOver | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDragOverCapture | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDragStart | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDragStartCapture | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDrop | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDropCapture | AdaptChildDragEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDurationChange | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onDurationChangeCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onEmptied | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onEmptiedCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onEncrypted | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onEncryptedCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onEnded | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onEndedCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onError | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onErrorCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onFocus | AdaptChildFocusEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onFocusCapture | AdaptChildFocusEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onGotPointerCapture | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onGotPointerCaptureCapture | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onInput | AdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onInputCapture | AdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onInvalid | AdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onInvalidCapture | AdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onKeyDown | AdaptChildKeyboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onKeyDownCapture | AdaptChildKeyboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onKeyPress | AdaptChildKeyboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onKeyPressCapture | AdaptChildKeyboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onKeyUp | AdaptChildKeyboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onKeyUpCapture | AdaptChildKeyboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onLoad | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onLoadCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onLoadedData | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onLoadedDataCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onLoadedMetadata | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onLoadedMetadataCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onLoadStart | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onLoadStartCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onLostPointerCapture | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onLostPointerCaptureCapture | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onMouseDown | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onMouseDownCapture | AdaptChildMouseEventHandler<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. |
onMouseMove | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onMouseMoveCapture | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onMouseOut | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onMouseOutCapture | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onMouseOver | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onMouseOverCapture | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onMouseUp | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onMouseUpCapture | AdaptChildMouseEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPaste | AdaptChildClipboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPasteCapture | AdaptChildClipboardEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPause | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPauseCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPlay | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPlayCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPlaying | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPlayingCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerCancel | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerCancelCapture | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerDown | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerDownCapture | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerEnter | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerEnterCapture | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerLeave | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerLeaveCapture | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerMove | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerMoveCapture | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerOut | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerOutCapture | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerOver | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerOverCapture | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerUp | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onPointerUpCapture | AdaptChildPointerEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onProgress | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onProgressCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onRateChange | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onRateChangeCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onReset | AdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onResetCapture | AdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onScroll | AdaptChildUIEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onScrollCapture | AdaptChildUIEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onSeeked | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onSeekedCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onSeeking | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onSeekingCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onSelect | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onSelectCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onStalled | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onStalledCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onSubmit | AdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onSubmitCapture | AdaptChildFormEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onSuspend | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onSuspendCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onTimeUpdate | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onTimeUpdateCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onTouchCancel | AdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onTouchCancelCapture | AdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onTouchEnd | AdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onTouchEndCapture | AdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onTouchMove | AdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onTouchMoveCapture | AdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onTouchStart | AdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onTouchStartCapture | AdaptChildTouchEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onTransitionEnd | AdaptChildTransitionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onTransitionEndCapture | AdaptChildTransitionEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onVolumeChange | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onVolumeChangeCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onWaiting | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onWaitingCapture | AdaptChildReactEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onWheel | AdaptChildWheelEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
onWheelCapture | AdaptChildWheelEventHandler<LegendPayload, ReactElement<unknown, string | JSXElementConstructor<any>>> | — | — |
Also accepts all aria-* attributes.
ChartTooltipContent
Import ChartTooltipContent from @/components/application/charts/charts-base. Renders a <div> element.
| Prop | Type | Default | Description |
|---|---|---|---|
isRadialChart | boolean | — | 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. |
isPieChart | boolean | — | 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. |
label | string | — | 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. |
payload | any | — | 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)
| Prop | Type | Default | Description |
|---|---|---|---|
active | boolean | — | 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. |
allowEscapeViewBox | AllowInDimension | { x: false, y: false } | This option allows the tooltip to extend beyond the viewBox of the chart itself. |
animationDuration | number | 400 | Specifies the duration of animation, the unit of this option is ms. |
animationEasing | EasingInput | ease | The type of easing function. |
axisId | AxisId | 0 | Tooltip always attaches itself to the "Tooltip" axis. Which axis is it?Depends on the layout:
|
content | ContentType<ValueType, NameType> | — | Renders the content of the tooltip.This should return HTML elements, not SVG elements.
|
contentStyle | CSSProperties | — | — |
cursor | CursorDefinition | true | If 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. |
defaultIndex | number | TooltipIndex | — | — |
filterNull | boolean | true | When an item of the payload has value null or undefined, this item won't be displayed. |
formatter | Formatter<TValue, TName> | — | — |
includeHidden | boolean | false | If 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" | auto | If 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) | — | — |
itemStyle | CSSProperties | — | — |
labelClassName | string | — | — |
labelFormatter | (label: ReactNode, payload: ReadonlyArray<Payload<TValue, TName>>) => ReactNode | — | — |
labelStyle | CSSProperties | — | — |
offset | number | Coordinate | 10 | The 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). |
payloadUniqBy | UniqueOption<TooltipPayloadEntry> | — | — |
portal | HTMLElement | 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. |
position | Partial<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. |
reverseDirection | AllowInDimension | { x: false, y: false } | — |
separator | string | — | — |
shared | boolean | — | Defines whether the tooltip is reacting to the current data point, or to all data points at the current axis coordinate.
|
trigger | "hover""click" | hover | If hover then the Tooltip shows on mouse enter and hides on mouse leave.If click then the Tooltip shows after clicking and stays active. |
useTranslate3d | boolean | false | — |
wrapperClassName | string | — | — |
wrapperStyle | CSSProperties | — | 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.