Etch component
Tooltip 1
Help icon that shows a short explanation on hover or keyboard focus. Screen readers get the text from the button's label.
Documentation
A help icon that shows a short explanation on hover or keyboard focus, such as next to a form field or a price.
How to use it
- Set Content, the explanation, and Label, what the button is about ("More information" by default).
- Its colors, the icon's and button's sizes and the bubble's width are CSS recipes, below. Try them in the preview's Styles tab, then paste the ones you pick in the site's
mainstylesheet.
Good to know
- Screen readers hear the label and the content together from the button, so the bubble itself is hidden from them.
- While it's hidden, the bubble isn't drawn at all, so a page can hold many tooltips without slowing down.
- Keep the content short: it shows only while the pointer or the focus is on the icon.
- Escape hides a tooltip that's shown. It shows again once the pointer and the focus have left it.
CSS recipes
--mac-tooltip-1-background-color (white), --mac-tooltip-1-text-color (the body text's color) and --mac-tooltip-1-border-color (white) set the bubble's colors, --mac-tooltip-1-icon-size (1em) and --mac-tooltip-1-trigger-size (1.25em) the icon and the button around it, and --mac-tooltip-1-max-width (20rem) the bubble's widest. A recipe changes every Tooltip 1 on the site. Paste it in the site's main stylesheet, which Etch prints after the components' styles.
With a border
For tooltips on white sections, a gray line round the white bubble, so it stands out from the page.
/* Tooltip 1's bubble with a gray line */
.mac-tooltip-1 {
--mac-tooltip-1-border-color: var(--border-color-dark);
}
Dark
For a bubble that stands out on any section, white text on the site's darkest neutral.
/* Tooltip 1's bubble dark, its text white */
.mac-tooltip-1 {
--mac-tooltip-1-background-color: var(--neutral-ultra-dark);
--mac-tooltip-1-text-color: var(--white);
--mac-tooltip-1-border-color: var(--neutral-ultra-dark);
}
On the brand color
For a bubble in the brand's color, white text on --primary. Use it only when white text reads well on the site's primary color, at a contrast of 4.5:1 or more.
/* Tooltip 1's bubble in the primary color, its text white */
.mac-tooltip-1 {
--mac-tooltip-1-background-color: var(--primary);
--mac-tooltip-1-text-color: var(--white);
--mac-tooltip-1-border-color: var(--primary);
}
A wider bubble
For explanations of a few lines, a bubble up to 28rem wide instead of 20rem, so they wrap less. It stays within the screen on phones.
/* Tooltip 1's bubble up to 28rem wide */
.mac-tooltip-1 {
--mac-tooltip-1-max-width: 28rem;
}
Reference
Read from the component's JSON, so it's always current.
Loading the reference