Skip to content

Components · Overlays

Tooltip

Supplementary text on hover and focus.

@rookcom/monarch-reactComponent

On an icon button

Usage examples

The example at the top of the page is the only one for this component.

Purpose

Short supplementary text about a control, shown on hover and keyboard focus.

Use when

  • Naming or clarifying an icon-only control.

Avoid when

  • Essential information or interactive content: use Popover or visible text.

Design principles

  • Never put essential information or interactive content in a tooltip.
  • Mount TooltipProvider once near the root so the open delay is shared.

API reference

import { Tooltip, TooltipProvider } from '@rookcom/monarch-react';
ExportKindRenderingRoot class
Tooltipcomponentclient.mn-tooltip
TooltipProvidercomponentclient.mn-tooltip

Tooltip wraps a single focusable child as the Radix trigger (asChild).

TooltipProvider sets delayDuration (default 400 ms) for all tooltips below it.

Generated from the TypeScript declarations of packages/react/src/components/overlays/tooltip.

Properties

Tooltip

Shows on hover and keyboard focus; Escape dismisses it.

PropTypeDescription
children requiredReactElement<unknown, string | import("/home/runner/work/monarch/monarch/node_modules/@types/react/index").JSXElementConstructor<any>>A single focusable element.
content requiredReactNodeSupplementary text. Never put essential information or interactive content here.
align"center" | "start" | "end"
defaultOpenboolean
onOpenChange((open: boolean) => void)
openboolean
side"top" | "right" | "bottom" | "left"

TooltipProvider

Mount once near the root. Shares the open delay across tooltips.

PropTypeDescription
children requiredReactNode
delayDurationnumber

Variants

PropValuesDescription
side'top''right''bottom''left'Preferred side. Default top.
align'start''center''end'Alignment on that side. Default center.

States

StateExposed asBehaviour
Open / closed–Controlled with open / onOpenChange or uncontrolled with defaultOpen.

Interaction behaviour

  • Opens after the provider delay on hover, and on keyboard focus.
  • Escape dismisses it.

Keyboard support

KeysAction
TabFocusing the trigger opens the tooltip.
EscapeDismisses the tooltip.

Accessibility

Role
tooltip
Accessible name
Its text becomes the trigger’s accessible description.
  • The trigger keeps its own accessible name; the tooltip only describes it.

Responsive behaviour

  • At most 18rem wide. Hover does not exist on touch screens, so never rely on a tooltip there.

Theme support

  • Inverse surface (--mn-color-bg-inverse / --mn-color-text-inverse), so it contrasts with the page in light and dark themes.

Do and don't

Do

  • Wrap a single focusable element.

Don't

  • Do not use a tooltip as the only accessible name of a control; IconButton has label for that.
  • Popover: Interactive floating content.
  • Button: IconButton, the usual trigger.

Dependencies

KindDepends on
npm packages@radix-ui/react-tooltip
Monarch componentsNone

Testing coverage

  • Appears on keyboard focus and becomes the trigger’s accessible description.
  • No axe violations in jsdom.
  • Renders on the server.
CheckCovered
Axe in jsdomYes
Server renderingYes
Browser suitesVisual baselines: /__gallery

Tests: packages/react/src/components/overlays/tooltip