Tooltips
On this page
A tooltip is a short hint that appears above a control when the pointer rests on it or it gets
keyboard focus. Add one with the data-ph-tooltip attribute; there's no script to call.


Figure 1: A tooltip on an icon button
<button type="button" class="ph-icon-btn" aria-label="Refresh" data-ph-tooltip="Refresh orders">
...svg...
</button>
<button type="button" class="ph-btn" data-ph-tooltip="Opens the side panel">Details</button>
| Attribute | What it does |
|---|---|
data-ph-tooltip="Text" | Shows the text above the element on hover and keyboard focus, after 0.3 seconds |
data-ph-tooltip-position="bottom" | Shows it below instead (for controls at the top of the page) |
Accessibility
- Put tooltips only on elements that can take focus (buttons and links), so keyboard users see them too.
- Screen readers don't read the tooltip. Give icon-only buttons an
aria-labelas well; the tooltip can repeat it.
Guidelines
- Keep it to a few words. If it needs a sentence, put a hint on the page instead.
- Don't hide information people need in a tooltip: touch screens can't hover.
- Every icon-only button should have one.