DitherCharts

Tooltip

Updated

Tooltip describes the control it wraps in a solid ink tip. It shows on mouse hover after a short delay or at once on keyboard focus, hides on Escape, and flips or slides to stay on screen. Like the charts, it takes your theme's ink and paper, light or dark, and needs no Tailwind.

Example

import "@/components/dithercharts/controls.css"
import { Tooltip } from "@/components/dithercharts/tooltip"

// Wrap one focusable element; it gets aria-describedby pointing at the tip.
<Tooltip content="Download the table as CSV">
  <Button onClick={exportCsv}>Export</Button>
</Tooltip>

Install

Controls install with DitherCharts Pro. See Installation to log in, then import controls.css once, e.g. in your root layout.

npx dithercharts add tooltip

Props

It renders a native element, so every other attribute that element takes passes through.

Tooltip props
PropTypeDefaultDescription
contentrequiredType ReactNodeDefault –The tip. Keep it short: it's read as the trigger's description.
childrenrequiredType ReactElement<{ "aria-describedby"?: string }>Default –One focusable element, e.g. a Button. It gets aria-describedby pointing at the tip.
collisionPaddingType { top?: number }Default 8Space in px the tip keeps clear at the window's top, e.g. a sticky header's height; it flips below to keep it.
classNameType stringDefault –