Live demo
Demo source
Use a tooltip for a brief, helpful hint: what an icon button does, what an abbreviation means, or a shortcut. Keep it to a few words. Don't put essential information in a tooltip, because touch users may never see it, and don't put links or buttons inside one; use a popover for interactive content.
Anatomy
A tooltip reading Tooltip message. Callouts mark 1 the content and 2 the arrow below it.
- Content: the
message, with optional non-interactive detail in thecontentslot. - Arrow: points to the trigger.
The trigger is the element in the default slot. It must be focusable, such as
a button, or have tabindex="0".
Look and feel
Spark and Ocean provide the tooltip surface and arrow in light and dark modes. Keep custom content brief and non-interactive; if many elements need long explanations, improve the visible labels instead.
Placement
Use top, right, bottom or left, with optional -start or -end
alignment; bottom is the default. Positioning adjusts when space is tight.
Use strategy="fixed" when the tooltip needs to escape a scrolling or clipped
container; the default is absolute. Check placement at viewport edges.
Behaviour
The tooltip opens when the pointer rests on the trigger or the trigger gets
keyboard focus, after enterDelay milliseconds. It closes when the pointer
leaves, focus moves away or Escape is pressed. openChanged reports
when it opens and closes; there is no open property.
Accessibility
The message isn't linked to the trigger for assistive technology, so give every trigger its own accessible name.