Tooltip

A small floating label that appears on hover or focus to describe an element.

Import

import { Tooltip } from '@matix/components/tooltip';

Usage

Without Arrow

The arrow is shown by default. Set arrow={false} on Tooltip.Popup to hide it.

Custom Delay

Adjust delay and closeDelay on Tooltip.Root to control timing. Defaults are delay={200} and closeDelay={0}.

<Tooltip.Root delay={0}>
  <Tooltip.Trigger>Instant</Tooltip.Trigger>
  <Tooltip.Portal>
    <Tooltip.Positioner>
      <Tooltip.Popup>No delay</Tooltip.Popup>
    </Tooltip.Positioner>
  </Tooltip.Portal>
</Tooltip.Root>

<Tooltip.Root delay={1000}>
  <Tooltip.Trigger>Slow</Tooltip.Trigger>
  <Tooltip.Portal>
    <Tooltip.Positioner>
      <Tooltip.Popup>1 second delay</Tooltip.Popup>
    </Tooltip.Positioner>
  </Tooltip.Portal>
</Tooltip.Root>

Placement

Control positioning via the side and align props on Tooltip.Positioner.

Custom Styles

Use the sx prop on Tooltip.Popup to override styles.

import * as stylex from '@stylexjs/stylex';

const custom = stylex.create({
  popup: { backgroundColor: '#1a1a2e', color: '#eaeaea', borderRadius: '8px' },
});

<Tooltip.Root>
  <Tooltip.Trigger>Styled tooltip</Tooltip.Trigger>
  <Tooltip.Portal>
    <Tooltip.Positioner>
      <Tooltip.Popup sx={custom.popup}>Custom styled tooltip</Tooltip.Popup>
    </Tooltip.Positioner>
  </Tooltip.Portal>
</Tooltip.Root>;

Server Components

Tooltip is a client component. A Server Component cannot read a property of a client component, so Tooltip.Root is undefined there. In a Server Component, import the named parts. Each Tooltip.<Part> is also exported as Tooltip<Part>.

import {
  TooltipRoot,
  TooltipTrigger,
  TooltipPortal,
  TooltipPositioner,
  TooltipPopup,
} from '@matix/components/tooltip';

In a client component, both forms work.

API Reference

ComponentPropTypeDefaultDescription
Tooltip.Rootopenboolean—Controlled open state
Tooltip.RootonOpenChange(open: boolean) => void—Called when the open state changes
Tooltip.Rootdelaynumber200Milliseconds to wait before showing the tooltip
Tooltip.RootcloseDelaynumber0Milliseconds to wait before hiding the tooltip
Tooltip.Trigger———The element that triggers the tooltip on hover/focus
Tooltip.PortalcontainerHTMLElementdocument.bodyPortal target
Tooltip.Positionerside'top' | 'right' | 'bottom' | 'left''top'Preferred side
Tooltip.Positioneralign'start' | 'center' | 'end''center'Alignment along the side
Tooltip.PopuparrowbooleantrueShow arrow pointer toward the trigger
Tooltip.PopupsxStyleXStyles—StyleX style override

All sub-components forward additional props to their underlying Base UI elements.

Accessibility

  • Built on Base UI Tooltip.
  • The tooltip is visual only. Screen readers do not announce it. Give the trigger its own accessible name, for example aria-label on an IconButton.
  • Shows on hover and focus, hides on blur and pointer leave.
  • The pointer can move onto the tooltip without closing it (WCAG 1.4.13).
  • Not interactive -- tooltips contain only text, no focusable elements.

Keyboard

KeyAction
EscapeCloses the tooltip
Tab (to trigger)Shows the tooltip via focus
Tab (away)Hides the tooltip via blur