Chart Tooltip

A composable tooltip for chart data points with customizable indicators, labels, and value formatters.

Usage

January
Revenue$12,400
Expenses$8,200
"use client";

import { ChartTooltip } from "@thenamespace/uikit";

export const DemoDefaultExample = () => (

Anatomy

Import the ChartTooltip component and access all parts using dot notation.

import { ChartTooltip } from "@thenamespace/uikit";

<ChartTooltip>
  <ChartTooltip.Header />
  <ChartTooltip.Item>
    <ChartTooltip.Indicator />
    <ChartTooltip.Label />
    <ChartTooltip.Value />
  </ChartTooltip.Item>
</ChartTooltip>;

Auto Content

February
Revenue18200
Expenses9800
Q1 2025
Organic22000
Paid Ads14500
Referral5200
"use client";

import { ChartTooltip } from "@thenamespace/uikit";

export const DemoAutoContentExample = () => (

Chart Colors

All Chart Colors
chart-1Lightest
chart-2Light
chart-3Accent
chart-4Darkest
Line Indicators
chart-1Lightest
chart-2Light
chart-3Accent
chart-4Darkest
"use client";

import { ChartTooltip } from "@thenamespace/uikit";

const chartColors = [

Custom Formatters

January 15, 2025
Portfolio$24,801.32
Benchmark$21,500
"use client";

import { ChartTooltip } from "@thenamespace/uikit";

export const DemoCustomFormattersExample = () => (

Inactive

The tooltip below is inactive (active=false) — nothing should render:

(empty — tooltip hidden)
"use client";

import { ChartTooltip } from "@thenamespace/uikit";

export const DemoInactiveExample = () => (

Line Indicator

March 2025
Organic15,200
Paid Ads8,400
Referral3,100
"use client";

import { ChartTooltip } from "@thenamespace/uikit";

export const DemoLineIndicatorExample = () => (

No Header

Sales458
"use client";

import { ChartTooltip } from "@thenamespace/uikit";

export const DemoNoHeaderExample = () => (

CSS Classes

Element Classes

  • .chart-tooltip — Root tooltip card container. Rounded border with surface background and overlay shadow.
  • .chart-tooltip__header — Optional title row (e.g., the X-axis label). Muted 12px medium text.
  • .chart-tooltip__item — A single series entry row. Flex layout with gap.
  • .chart-tooltip__indicator — Color marker next to the series name.
  • .chart-tooltip__indicator--dot — Dot-shaped indicator. Small circle (8px).
  • .chart-tooltip__indicator--line — Line-shaped indicator. Tall narrow pill (12px × 4px).
  • .chart-tooltip__label — Series name text. Muted 12px, fills available space.
  • .chart-tooltip__value — Series data value. Semibold 12px foreground text.

API Reference

ChartTooltip

The root tooltip container. Controls visibility and indicator style via context.

PropTypeDefaultDescription
activebooleantrueControls visibility. When false, the tooltip is not rendered.
indicator"dot" | "line""dot"Shape of the color indicator next to each series name.
childrenReactNodeTooltip content — typically Header, Item, Indicator, Label, and Value sub-components.

Also supports all native div HTML attributes.

ChartTooltip.Content

Auto-renders a tooltip from Recharts payload data. Pass as the content prop of a Recharts <Tooltip>:

<Tooltip content={<ChartTooltip.Content />} />
PropTypeDefaultDescription
activebooleanProvided by Recharts — whether the tooltip is active.
labelnumber | stringProvided by Recharts — the X-axis label for the hovered data point.
payloadRechartsPayloadEntry[]Provided by Recharts — array of series data for the hovered point.
hideHeaderbooleanfalseHide the header row.
indicator"dot" | "line""dot"Shape of the color indicator.
labelFormatter(label: number | string) => ReactNodeCustom formatter for the header label.
valueFormatter(value: number | string) => ReactNodeCustom formatter for series values.

ChartTooltip.Header

Optional title row rendered above the series items.

PropTypeDefaultDescription
childrenReactNodeHeader content (typically the X-axis label text).

Also supports all native div HTML attributes.

ChartTooltip.Item

A single series entry row containing an indicator, label, and value.

PropTypeDefaultDescription
childrenReactNodeRow content — typically Indicator, Label, and Value sub-components.

Also supports all native div HTML attributes.

ChartTooltip.Indicator

Color marker rendered next to the series name. Shape is controlled by the root indicator variant.

PropTypeDefaultDescription
colorstringCSS color value for the indicator background.

Also supports all native span HTML attributes.

ChartTooltip.Label

Series name text displayed between the indicator and value.

PropTypeDefaultDescription
childrenReactNodeLabel content (typically the series name or dataKey).

Also supports all native span HTML attributes.

ChartTooltip.Value

Series data value displayed at the end of each item row.

PropTypeDefaultDescription
childrenReactNodeValue content (typically the formatted numeric value).

Also supports all native span HTML attributes.