Tooltip
A short text label shown on hover, keyboard focus or long-press: to name icon-only buttons and give brief hints. Keep it to a few words, never put actions in it, and never make it the only way to get information. Rules: UX Elements & Rules → Tooltip (R-O2).
Add it to a page
Load the pinned file once in your Latitude Site or web page, then use the tag.
<script type="module" src="https://web-components.sites.latd.com/components/lat-tooltip/0.1.0/lat-tooltip.js"></script>The file is an ES module. It loads Lit, the design-system tokens and the Roobert stylesheet from this catalog once per page, however many components you use.
| Version | 0.1.0 |
|---|---|
| File | /components/lat-tooltip/0.1.0/lat-tooltip.js (2.7 KB gzipped) |
| SHA-256 | 98186d539a8e23296b62af14b16a204dd3c1b1dff021d43a50a480b824f42a42 |
Place it right after its trigger, or point to the trigger's id with for. The trigger gets aria-describedby, so screen readers read the tooltip as its description. Give an icon button its own label as well: the label names it, the tooltip shows that name to sighted users.
Permutations
Hover a trigger for a second, or Tab to it. Once one tooltip has shown, the next shows at once for a second. Escape hides it.
On icon buttons: hover, focus or long-press
<lat-icon-button label="Copy link"><lat-icon name="link"></lat-icon></lat-icon-button>
<lat-tooltip>Copy link</lat-tooltip>
<lat-icon-button label="Upload"><lat-icon name="upload"></lat-icon></lat-icon-button>
<lat-tooltip shortcut="⌘U">Upload</lat-tooltip>
<lat-icon-button label="Ask AI" variant="primary"><lat-icon name="ai"></lat-icon></lat-icon-button>
<lat-tooltip prominent>New: AI insights</lat-tooltip>Placements
<lat-button size="sm">Below</lat-button>
<lat-tooltip>Shown below by default</lat-tooltip>
<lat-button size="sm">Above</lat-button>
<lat-tooltip placement="above">Shown above</lat-tooltip>
<lat-button size="sm">Right</lat-button>
<lat-tooltip placement="right">Shown right</lat-tooltip>
<lat-button size="sm">Left</lat-button>
<lat-tooltip placement="left">Shown left</lat-tooltip>Shown in place
<lat-tooltip inline>Copy link</lat-tooltip>
<lat-tooltip inline shortcut="⌘U">Upload</lat-tooltip>
<lat-tooltip inline prominent>New: AI insights</lat-tooltip>
<lat-tooltip inline placement="above">Above</lat-tooltip>
<lat-tooltip inline placement="right">Right</lat-tooltip>
<lat-tooltip inline placement="left">Left</lat-tooltip>Attached by id
<lat-icon-button id="share-study" label="Share"><lat-icon name="share"></lat-icon></lat-icon-button>
<lat-tooltip for="share-study">Share</lat-tooltip>Attributes
| Attribute | Values | Notes |
|---|---|---|
for | id | The trigger. Without it, the element just before the tooltip. |
placement | below (default), above, right, left | Above when most interactive elements are at the bottom; right when elements are stacked on the left, left when stacked on the right. Flips when there's no room. |
prominent | boolean | For announcements. |
shortcut | text | A keyboard shortcut in a key cap, such as ⌘U. |
open | boolean | Whether it's showing. show() and hide() work too. |
inline | boolean | Shows it in the page flow, always visible and detached from any trigger. For previews and mockups. |