Tooltip

A short label that appears on hover after a delay and immediately on focus.

Import

tsx
import { Tooltip } from "@merid/react";

Anatomy

Tooltip is a single component. Its child must be one focusable element that forwards its ref, such as Button or IconButton. The tooltip adds aria-describedby and pointer and focus handlers to that element.

tsx
<Tooltip content="…">
  <Button />
</Tooltip>

Examples

Placement

Delay and disabled

tsx
<Tooltip content="Saved" delay={0}>…</Tooltip>
<Tooltip content="Unavailable offline" disabled={isOnline}>…</Tooltip>

API reference

PropTypeDefaultDescription
contentRequiredReactNode–Tooltip text. Keep it short and non-interactive.
childrenRequiredReactElement–A single focusable element (e.g. an icon Button). Receives aria-describedby.
openboolean–Controlled open state.
defaultOpenbooleanfalseInitial open state when uncontrolled.
onOpenChange(open: boolean) => void–Called when the open state should change.
delaynumber400Hover delay before opening, in ms. Focus opens immediately.
placementPlacement"top"Preferred placement.
sideOffsetnumber6Distance from the trigger in px.
classNamestring–Class name for the tooltip bubble.
disabledbooleanfalseDo not show the tooltip.
containerElement | nulldocument.bodyPortal target. `undefined` uses `document.body`; `null` renders nothing until the target exists.

Styling

.mrd-tooltip is the bubble: --mrd-tooltip-bg / --mrd-tooltip-fg, --mrd-radius-sm, --mrd-shadow-lg, 280px max width, z-index: var(--mrd-z-tooltip). It carries data-state="open" and pointer-events: none.

Accessibility

Follows the WAI-ARIA Tooltip pattern. The bubble has role="tooltip" and is linked to the trigger with aria-describedby while open. Touch pointers do not open it, so never put essential information only in a tooltip. An icon-only trigger still needs its own accessible name (IconButton's label).

KeyAction
TabFocusing the trigger shows the tooltip immediately; moving focus away hides it.
EscHides the tooltip.

Guidelines

Do

Use a tooltip to name an icon-only control or add a brief hint.

Avoid

Put links, buttons or long text in a tooltip; use a Popover.