Theme studio

Design a theme, preview it live, then export it. Saved in this browser.

Quick picks #10b981
Generated scale
50100200300400500600700800900
Some text is below AA

ChartTooltip

  • Stable
  • WCAG 2.2 evidence
  • RTL

The content of a chart's hover and focus tooltip: a card with a caption and rows of marker, label and value. Presentational and content-only: it renders in React Server Components, does not position itself and has no behaviour. The chart (client code) decides when it is shown and where; useChartTooltip (same folder) implements the show, hide, Escape and hoverable behaviour and placeChartTooltip the position. The root is role="tooltip". Pass an id and point the data point's aria-describedby at it while it is shown (WCAG 1.3.1, 4.1.2), pass style (for example position: absolute with left and top) and className to position it, and ref to measure it. Rows are a description list (term = series, definition = value). The series markers differ by shape or dash as well as colour, like the legend's (WCAG 1.4.1). Long labels wrap. The card does not capture the pointer away, so the pointer can move onto it (WCAG 1.4.13); the same values are in the chart's data table. Consumer duties: never keep information only in a tooltip (the table has it), format values for the locale, keep the series wording identical to the legend, and close the tooltip with Escape.

import { ChartTooltip } from "@nexera-ui/react";
Loading example…
6
examples
3
props
2
live controls
1
platform
9
WCAG criteria
1
block uses it

Try every prop. Copy the code.

Change the props and the code updates. Check light and dark, LTR and RTL, and phone width.

Loading…
title
children
Generated code
import { ChartTooltip } from "@nexera-ui/react";

<ChartTooltip />

Examples 5

The same examples as Storybook, rendered live. Open Code to copy one.

Series markers

Markers of the eight series and the swatch kinds. Every series has a different glyph or dash as well as a different colour (WCAG 1.4.1); the glyphs repeat after four series, so give long series lists a legend with hasMarker lines.

Loading example…

Title rows and note

Rows are optional, and children takes free content after them (a note, a total).

Loading example…

Long labels

Long captions and labels wrap inside the 20 rem maximum width instead of overflowing.

Loading example…

Right to left

Right-to-left: the card, the padding and the rows mirror; the digits follow the locale.

Loading example…

On data points

Shows the pieces a chart combines: useChartTooltip (hover, focus, Escape, hoverable), placeChartTooltip (flip and clamp) and the ChartTooltip card. Tab into the points, move with the arrow keys, press Escape to dismiss, hover a point and move the pointer onto the card. A real chart also draws axes and a data table; this is only the tooltip wiring.

Loading example…

Props 3

Press "Try it" on a card to load that prop into the playground.

3 props shown

titleNexera
ReactNode

Caption of the data point: the date, category or x value the rows belong to. Shown when provided.

Default –
rowsNexera
readonly ChartTooltipRow[]

Rows of the card. Shown after the title when not empty.

Default –
childrenNexera
ReactNode

Free content shown after the rows, for what a row cannot say (a note, a link-free explanation).

Default –

* Required. React Aria props shown are the ones most apps use; the component accepts the rest of its React Aria props too.

Accessible by default.

Built on React Aria, and covered by the WCAG 2.2 evidence generated on every build.

WCAG 2.2 evidence

5 direct · 4 supporting
  • 1.1.1Non-text ContentLevel A · tested directly
  • 1.3.1Info and RelationshipsLevel A · tested directly
  • 1.3.2Meaningful SequenceLevel A · supporting test
  • 1.4.1Use of ColorLevel A · supporting test
  • 1.4.10ReflowLevel AA · supporting test
  • 1.4.12Text SpacingLevel AA · supporting test
  • 1.4.13Content on Hover or FocusLevel AA · tested directly
  • 2.1.1KeyboardLevel A · tested directly
  • 4.1.2Name, Role, ValueLevel A · tested directly

Fits any width.

Nexera components respond to the space they are given. Drag the corner of the frame, or pick a width.

0 px · drag the corner

Styling hooks

Pass className to add Tailwind classes (merged last). State is exposed as data attributes, so you can style it with variants like data-pressed:.

Usage
<ChartTooltip className="shadow-sm" />

Used in blocks

Related components