Create

General

Tooltip

Copy page View as Markdown Open in ChatGPT Open in Claude

A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.

Usage#

app.component.ts
import { WdsTooltipComponent } from '@wds/angular/tooltip';

Put the element the tooltip describes in the trigger slot and the text in the default slot. The trigger must be focusable, so keyboard users can open the tooltip too.

Examples#

Default#

The tooltip opens when the pointer rests over the trigger (200 ms) or the trigger gets keyboard focus, and closes when they leave, on a click or on Escape. It stays open while the pointer is over the bubble.

Hover Add to library

Side#

side places the tooltip top (default), right, bottom or left of the trigger, and align along it (start, center, end). Without enough space the tooltip flips to the other side.

Left Add to library Top Add to library Bottom Add to library Right Add to library

Toolbar#

Icon buttons name their action with label and show it in a tooltip. When the tooltip only repeats the name, it is not added as a description. Once one tooltip is open, moving to the next button opens its tooltip at once, without the delay.

Bold Italic Underline

Keyboard shortcut#

A wds-kbd in a tooltip gets colors that fit the dark bubble. Give the button aria-keyshortcuts as well, so screen readers announce the shortcut.

Save CtrlS

Description#

A tooltip that says more than the name becomes the description of the trigger (aria-description): screen readers read "Notifications, button, 3 unread notifications".

3 unread notifications

Rich content#

The bubble can hold a title and a few lines of text (up to --wds-tooltip-max-width, default 20rem). Keep it short and without links or buttons: the bubble cannot be focused. For interactive content use Popover.

Version history Pro
Pro feature Version history keeps every change for 90 days. It is part of the Pro plan.

Disabled button#

A disabled button cannot be focused and gets no pointer events, so wrap it in an element with tabindex="0" and make that the trigger. The tooltip can then explain why the action is not available.

Publish Only editors can publish

Delay and arrow#

On hover the tooltip opens after delay milliseconds (default 200), so tooltips do not flash while the pointer crosses the page. Keyboard focus opens it at once. delay="0" opens it on hover at once, hide-arrow removes the arrow.

Default Opens after 200 ms No delay Opens at once No arrow Without the arrow

API References#

wds-tooltip#

A short text label that appears when the trigger is hovered or focused with the keyboard. The bubble opens in the top layer (Popover API) and stays open while the pointer is over it, so its text can be selected and zoomed in. The tooltip text becomes the trigger's description (aria-description). When it only repeats the trigger's name (e.g. an icon button with label="Bold" and the tooltip "Bold"), it is not added, so screen readers do not read the name twice. A tooltip holds plain text: no links or buttons, use wds-popover for those.

Attributes

AttributeTypeDefaultDescription
openbooleanfalseWhether the tooltip is visible. Also set by show() and hide().
sideWdsTooltipSide'top'Side of the trigger. Flips when there is not enough space.
alignWdsTooltipAlign'center'Alignment along the trigger.
offsetnumber8Distance from the trigger in px.
delaynumber200Delay in ms between the pointer entering the trigger and the tooltip opening, so tooltips do not flash while the pointer passes over the page. Keyboard focus opens it at once, and so does moving to the next trigger while a tooltip is open or has just closed.
disabledbooleanfalseTurns the tooltip off (it does not open, and an open one closes).
hide-arrow.hideArrowbooleanfalseHides the arrow.

Events

EventDescription
wds-open-changeCustomEvent<WdsTooltipOpenChangeDetail>The tooltip opens or closes.

Methods

MethodDescription
show()Shows the tooltip.
hide()Hides the tooltip.

Slots

SlotDescription
triggerThe element the tooltip describes (e.g. wds-button). It must be focusable: wrap a disabled button in an element with tabindex="0".
(default)Tooltip text. A wds-kbd gets colors that fit the dark bubble.

CSS parts (::part)

PartDescription
contentThe bubble.
arrowThe arrow pointing at the trigger.

CSS custom properties

PropertyDescription
--wds-tooltip-bgBackground (default --wds-foreground).
--wds-tooltip-fgText color (default --wds-background).
--wds-tooltip-max-widthMaximum width of the bubble (default 20rem).

Accessibility#

Screen reader#

The bubble has role="tooltip". Its text is set as aria-description on the trigger (wds-button forwards it to the native button), so screen readers read it after the name and the role.

When the text is the same as the name of the trigger (its label, aria-label or text), no description is added, so the name is not read twice. Name icon buttons with label: a tooltip is not a name.

Do not put interactive elements (links, buttons) in a tooltip: it closes when focus leaves the trigger. Use wds-popover for them.

The tooltip follows WCAG 1.4.13 "Content on hover or focus": it can be dismissed with Escape without moving focus, the pointer can move onto it without closing it, and it stays until the pointer or focus leaves.

Touch screens have no hover, so a tooltip does not open on touch. Do not hide information that is needed to use the page only in a tooltip.

Keyboard support#

KeyFunction
TabMoves focus to the trigger and opens the tooltip. Moving focus away closes it.
EscapeCloses the tooltip; focus stays on the trigger.
Footer