Tooltip
Tooltips add additional context to interactive UI elements and appear on mouse hover or keyboard focus.
Page navigation navigation
- Reserve Tooltips to visually surface the label for IconButtons.
- Keep the Tooltip text minimal.
- Never include Tooltips on non-interactive components (
div,span,p) because it will not be accessible for keyboard or screen reader users.
Best practices
Edit in Figma
Edit in FigmaTooltip as a label
Edit in FigmaIconButtons have a visually hidden label utilizing aria-label. To instead display that label in a Tooltip, the label option should be used. The label serves as the accessible name for the control utilitizing aria-labelledby under the hood.
Tooltip as a description
The description is intended to supplement the control's text label by utilitizing aria-describedby under the hood, and will be announced to a screen reader in addition to the label. Keep the description short and concise.
IconButton with visually hidden label
Edit in FigmaIconButtons have a visually hidden label utilizing aria-label. To provide context in addition to the visually hidden label, use the description option.
Button with visible label
Edit in FigmaFor buttons that have a visible label, the description option can also be used to provide additional context.
Alternatives to Tooltips
Before adding a Tooltip, please consider: Is this information essential and necessary? Can the UI be made clearer? Can the information be shown on the page by default? See Tooltip alternatives for more accessible alternatives.
We use aria-label for Tooltip contents. However, aria-label replaces the text content of an element in screen readers, so only use Tooltip on elements with no existing text content.
A Tooltip may only be used on an element that is interactive such as a button or a link. Even if an element is focusable, a Tooltip may only be used if the element does something when it's clicked.
1. Persist the content
If possible, persist the content so it's always available rather than using a Tooltip, which hides content by default. This ensures that the content is always discovered and surfaced to users regardless of device.
Edit in Figma
Edit in Figma2. Don't duplicate content
If the Tooltip duplicates content that is already available on the page, remove it.
Edit in Figma
Edit in Figma3. Use a modal
Consider using a modal, which is accessible for mobile users and allows you to structure content that may otherwise be crammed into a Tooltip.
Edit in Figma
Edit in Figma4. Use a summary disclosure
Consider using a summary disclosure that is accessible for mobile users and also offers the ability to show or hide content.
Edit in Figma
Edit in FigmaOther
If you are unsure which alternative is more suited to your scenario and need help, consult a designer or the GitHub Accessibility team (if you are GitHub staff) for advice.