Skip to content

Tooltip

Alpha
Use tooltips to add context to elements on the page.

Tooltip only appears on mouse hover or keyboard focus and contain a label or description text. Use tooltips sparingly and as a last resort. Consider these alternatives.

When using a tooltip, follow the provided guidelines to avoid accessibility issues:

  • Tooltip text should be brief and to the point.
  • Tooltips should contain only non-essential text. Tooltips can easily be missed and are not accessible on touch devices so never use tooltips to convey critical information.

Examples

As a description for icon-only button

If the tooltip content provides supplementary description, wrap the target in a Tooltip. The trigger element should also have a concise accessible label via aria-label.

As a description for a button with visible label

With direction

Set direction of tooltip with direction. The tooltip is responsive and will automatically adjust direction to avoid cutting off.

Props

Tooltip

NameTypeDefaultDescription
children Required
React.ReactNode
Tooltip target, single element
text
string
The text content of the tooltip. This should be brief and no longer than a sentence
aria-label Deprecated
string
Use text instead
type
'description' | 'label'
'description'Use aria-describedby or aria-labelledby
direction
'nw' | 'n' | 'ne' | 'e' | 'se' | 's' | 'sw' | 'w'
'n'Sets where the tooltip renders in relation to the target
align Deprecated
'left' | 'right'
Use direction instead. Alignment relative to target
noDelay
boolean
falseWhen set to true, tooltip appears without any delay
wrap Deprecated
boolean
Use to allow text within tooltip to wrap. Deprecated: always set to true now.
sx
SystemStyleObject
Style overrides to apply to the component. See also overriding styles.

Status

Alpha

  • Component props are documented on primer.style/react.
  • Component does not have any unnecessary third-party dependencies.
  • Component can adapt to different themes.
  • Component can adapt to different screen sizes.
  • Component has 100% test coverage.

Beta

  • Component is used in a production application.
  • Common usage examples are documented on primer.style/react.
  • Common usage examples are documented in storybook stories.
  • Component has been reviewed by a systems designer and any resulting issues have been addressed.
  • Component has been manually reviewed by the accessibility team and any resulting issues have been addressed.

Stable

  • Component API has been stable with no breaking changes for at least one month.
  • Feedback on API usability has been sought from developers using the component and any resulting issues have been addressed.
  • Component has corresponding design guidelines documented in the interface guidelines.
  • Component has corresponding Figma component in the Primer Web library.

Further reading