Chart Tooltip
Preview: Lines
Import
import { ChartTooltip } from '@marbleui/ui'Props
<ChartTooltip>
| Prop | Type | Default | Description |
|---|---|---|---|
| containerWidth *required | number | — | |
| rows *required | TooltipRow[] | — | |
| x *required | number | — | |
| y *required | number | — | |
| title | ReactNode | — |
Usage notes
The hover card the built-in charts use: an optional title, then one row per series with a color key, value and label. The charts render their own; use ChartTooltip when you draw a custom plot inside ChartContainer.
<div className="relative">
<svg width={width} height={160}>{/* marks with pointer handlers */}</svg>
{hover && (
<ChartTooltip title={hover.month} x={hover.x} y={hover.y} containerWidth={width}
rows={[{ label: 'Organic', value: '5.9K', color: 'var(--chart-1)' }, { label: 'Paid', value: '2.4K', color: 'var(--chart-2)' }]} />
)}
</div>
- It is absolutely positioned at
x/yin px inside the nearest positioned parent, centred vertically ony, and flips to the left of the point whenxis within 180px ofcontainerWidth. - Rows take a preformatted
valuestring.shapeis'line'(default) for lines and areas,'square'for bars and slices; type rows withChartTooltipRow. Rows are keyed bylabel, so labels must be unique. - You own the show/hide state. The tooltip is
role="presentation"and ignores the pointer, so screen readers never hear it; make the same values available through the container’stable.
Example source · show· hide
import { ChartTooltip } from './chart-tooltip'
export const styles = {
Lines: () => (
<div className="relative h-32 w-80">
<ChartTooltip
title="Mar 2026"
x={0}
y={64}
containerWidth={600}
rows={[
{ label: 'Organic', value: '5.9K', color: 'var(--chart-1)' },
{ label: 'Paid', value: '2.4K', color: 'var(--chart-2)' },
{ label: 'Referral', value: '1.1K', color: 'var(--chart-3)' },
]}
/>
</div>
),
Bars: () => (
<div className="relative h-24 w-80">
<ChartTooltip title="Q3" x={0} y={48} containerWidth={600} rows={[{ label: 'Revenue', value: '$48.2K', color: 'var(--chart-1)', shape: 'square' }]} />
</div>
),
}Source: packages/ui/src/chart-tooltip/chart-tooltip.tsx
Catalog
- Category
- charts
- Priority
- Pro
- Primitive
- custom