Tooltip

A brief description of a focusable control, shown on hover after a delay and on keyboard focus at once.

<tp-tooltip>
Tooltip
Default density Compact density Restart from the initial state Show the copyable source
Download invoice as PDF

Usage

Put the control in the trigger slot and the description in the default slot. Hover opens after 600 ms, focus opens immediately, and Escape closes without moving focus. The text becomes the trigger’s accessible description; it never replaces the control’s name, so an icon button still needs its own aria-label. Pointer movement from the trigger into the content keeps it open. Touch does not create a persistent tooltip. Its description is associated with the actual focusable native control, including a Button’s shadow root.

Sides

side takes physical or logical values (block-start by default) and align positions the tooltip along that side. Collisions with the viewport can flip the resolved side. The positioner uses the browser top layer without moving authored content out of its theme or slot context. Flip, shift, available-size constraints, arrow placement and anchor visibility are recomputed on scroll, resize, content changes and layout movement. Hidden or disconnected anchors cannot leave a visible stale popup.

Sides
Default density Compact density Restart from the initial state Show the copyable source
AboveShown above AfterShown after the trigger BelowShown below BeforeShown before the trigger

Keyboard hints

Descriptions can include an Icon or Kbd. Links, buttons and inputs cannot go inside; use Popover for interactive content.

With a shortcut
Default density Compact density Restart from the initial state Show the copyable source
New issue Create an issue

Delay

open-delay and close-delay tune pointer timing in milliseconds. Keep the open delay for dense toolbars so tooltips don’t flash as the pointer passes; shorten it where the description is the point.

Delays
Default density Compact density Restart from the initial state Show the copyable source
InstantOpens with no delay PatientWaits 1.2 seconds to open

Following the pointer

track-cursor-axis positions the tooltip at the pointer along one or both axes, which suits wide targets such as a chart or a progress track.

Cursor tracking
Default density Compact density Restart from the initial state Show the copyable source
Storage: 42 GB of 100 GB used
Photos 28 GB · Documents 9 GB · Other 5 GB

Toolbar groups

In a toolbar, the first tooltip should wait but the next ones should not. Give the tooltips one TooltipProvider from @tweakpad/ui: after one opens, moving to a neighbour opens its tooltip at once, until the pointer has rested away for restTimeout (400 ms by default). Only one tooltip in the group is open at a time.

Shared provider
Default density Compact density Restart from the initial state Show the copyable source

One tooltip for many triggers

A long list does not need a tooltip per row. Create a handle with createTooltipHandle(), attach one Tooltip to it, and register each trigger with a payload. The Tooltip’s content renders the payload of whichever trigger is active, here with html from lit.

Shared handle
Default density Compact density Restart from the initial state Show the copyable source

registerTrigger() returns a cleanup function, and handle.open(identifier) opens the tooltip for one trigger from code.

Disabled

Disabled tooltip
Default density Compact density Restart from the initial state Show the copyable source
Archive Move this project to the archive

disabled on the Tooltip suppresses the description only; the Button it describes stays active and keeps its hover appearance.

API Reference

Every element also accepts motion-policy.

Properties

PropertyTypeDefaultDescriptiondescribesTooltipDescribes'trigger'trigger makes the text the trigger's accessible description; none keeps the tooltip visual only, for a trigger whose name already says the same, such as a Play button whose tooltip shows "Play" and its shortcut.

Events

EventTypeDescriptiontp-open-changeTpSurfaceOpenChangeEventCancelable proposal to open or close, before the surface changes; detail.value is the proposed state, detail.reason what asked (a trigger press, hover or focus, Escape, an outside press, a close action or code) and detail.trigger the trigger. On a close, detail.preventUnmountOnClose() keeps the content mounted.tp-open-change-completeCustomEvent<{ open: boolean; }>After the surface finishes opening or closing; detail.open.

Slots

SlotDescriptiondefaultThe description: text, with an Icon or a Kbd.triggerThe focusable control the tooltip describes.

CSS parts

PartDescription::part(tooltip)The host around the trigger and the tooltip.

Components, widgets and patterns that use this one.

Show more