Shows supplementary information about an element when the user interacts with it, for example on hover or focus. It supports custom placement, delays, a sticky mode and animations.
- Slots
-
default— The content of the tooltip. Replaces the `message` text. -
close-button— Slot for custom sticky-mode close action (e.g., an icon/button).
- CSS Parts
-
base— The wrapping container of the tooltip content. -
simple-text— Added to the base part when the tooltip shows the `message` text, not slotted content. -
close-button— The default sticky-mode close button.
Properties
Section titled "Properties"anchor
Section titled "anchor"An element instance or an IDREF to use as the anchor for the tooltip.
anchor: string | Element | undefined hideDelay
Section titled "hideDelay"The time in milliseconds before a hide trigger closes the tooltip. A negative value is the same as 0.
hideDelay: number hideTriggers
Section titled "hideTriggers"The anchor events that hide the tooltip. A list of event names, separated by commas or spaces.
hideTriggers: string message
Section titled "message"The plain-text content of the tooltip. Slotted content replaces it.
message: string placement
Section titled "placement"Where to place the tooltip relative to its anchor element.
placement: PopoverPlacement scrollStrategy
Section titled "scrollStrategy"The behavior of the tooltip when an ancestor scroll container scrolls.
If the value is hide, the tooltip hides while the anchor is fully out
of view. hide is the default value.
If the value is scroll, the tooltip stays visible and anchored.
If the value is close, the tooltip closes on each scroll, also in
sticky mode. The Escape key also closes a sticky tooltip.
scrollStrategy: PopoverScrollStrategy showDelay
Section titled "showDelay"The time in milliseconds before a show trigger opens the tooltip. A negative value is the same as 0.
showDelay: number showTriggers
Section titled "showTriggers"The anchor events that show the tooltip. A list of event names, separated by commas or spaces.
showTriggers: string sticky
Section titled "sticky"Whether the tooltip stays visible until the user closes it with the close button or the Escape key.
sticky: boolean withArrow
Section titled "withArrow"Whether to render an arrow indicator for the tooltip.
withArrow: boolean Methods
Section titled "Methods"Hides the tooltip if not already hidden.
hide(): Promise<boolean> Returns Promise<boolean>
Shows the tooltip if not already showing. If a target is provided, sets it as a transient anchor.
show(target: string | Element): Promise<boolean> Parameters
- target:
string | Element
Returns Promise<boolean>
showAt
Section titled "showAt"Shows the tooltip at a point or against a rectangle, in viewport
coordinates, for example at the clientX and clientY of a pointer event.
Without width and height, the rectangle is a point.
showAt(rect: TooltipRect): Promise<boolean> Parameters
- rect:
TooltipRect
Returns Promise<boolean>
toggle
Section titled "toggle"Toggles the tooltip between shown/hidden state.
toggle(): Promise<boolean> Returns Promise<boolean>
Events
Section titled "Events"onClosed
Section titled "onClosed"Emitted after the tooltip closes on a user interaction and is no longer visible.
onClosed(args: CustomEvent<void>): void Parameters
- args:
CustomEvent<void>
Returns void
onClosing
Section titled "onClosing"Emitted before the tooltip closes on a user interaction. Can be canceled to prevent closing. Not emitted for the
onClosing(args: CustomEvent<void>): void Parameters
- args:
CustomEvent<void>
Returns void
onOpened
Section titled "onOpened"Emitted after the tooltip opens on a user interaction and is visible.
onOpened(args: CustomEvent<void>): void Parameters
- args:
CustomEvent<void>
Returns void
onOpening
Section titled "onOpening"Emitted before the tooltip opens on a user interaction. Can be canceled to prevent opening.
onOpening(args: CustomEvent<void>): void Parameters
- args:
CustomEvent<void>