Tooltip

Use the tooltip component to display a short message when a user hovers or focuses an interactive element.

Ready to use
import {Tooltip} from '@primer/react-brand'

Examples

Default

Loading

Custom direction

By default, tooltips appear below the element. You can change the direction by passing the direction prop with a cardinal or diagonal direction. Supported values are n, ne, e, se, s, sw, w, and nw.

As long as there is enough room in the viewport, the tooltip will appear in the specified direction. If there is not enough room, the tooltip will appear in whatever direction it can place the tooltip without overflowing the viewport.

Loading

Delay

Tooltips use a short pointer delay by default to avoid appearing while the pointer passes over a trigger. Use medium or long for groups of familiar controls where immediate tooltips would be distracting. Keyboard focus always opens the tooltip immediately.

Loading

With an icon button

Use IconButton when a familiar Octicon can replace a visible text label. Its required aria-label provides the accessible name and automatically appears in a tooltip on hover and keyboard focus, so it does not need to be wrapped in Tooltip.

Use this with caution. It is generally better to use a visible label for better usability and accessibility.

Loading

For other custom icon-only controls, use type="label" to make the tooltip text the trigger’s accessible name.

Component props

nametypedefaultrequireddescription
direction'nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w''s'falseThe side the tooltip appears on
delay'short', 'medium', 'long''short'falsePointer hover delay: short (50ms), medium (400ms), or long (1200ms). Keyboard focus is immediate.
textstringundefinedtrueThe text to be displayed in the tooltip
type'description', 'label''description'falseThe tooltip’s semantic relationship to its trigger. label provides the accessible name, while description provides supplementary information alongside the trigger’s existing label.
  • Popover: For displaying more complex interactive content that appears when triggered
  • Button: Often used in conjunction with tooltips
  • Icon button: For familiar icon-only actions with automatic tooltips