Skip to content

Tooltip

A simple text prompt bubble triggered on hover or keyboard focus.

Basic usage

Trigger on hover

Hover to view

Placement

Four directions

UpDownLeftRight

When space is insufficient, the tooltip automatically flips along the main axis and avoids the viewport edges.

Arrow

By default an arrow pointing at the trigger element's edge is shown; arrow="false" hides the arrow; arrow-point-at-center makes the arrow point at the trigger element's center (when the panel is shifted by viewport-edge avoidance, the arrow still points at the anchor center).

Arrow visibility and pointing

DefaultNo arrowPoint at center

arrow-position="merge" merges the arrow with the panel corner into a right triangle (only for *-start / *-end placements).

Arrow merge mode

bottom-start + merge

Viewport auto adjust

By default the tooltip automatically flips along the main axis and avoids the viewport edges when space is insufficient; auto-adjust-overflow="false" disables the auto adjust so the panel keeps the declared placement (it may overflow the viewport).

Auto adjust disabled

Auto adjust off

Focus trigger

Trigger on keyboard focus

Focus me with Tab

Controlled display

The open attribute is controlled: an external button can set/remove open to show/hide the tooltip (hover/focus triggers still apply in addition).

Controlled display (open attribute)

ShowHideopen: falseTrigger element

Long text

Long text and max width

Hover to view long hint

Virtual trigger

Virtual mode (virtual) does not bind to a host trigger element: open is fully controlled externally, and the position is set by virtual-anchor (an anchor element selector) or virtual-x / virtual-y (viewport coordinates). placement still applies. It suits scenarios where a normal trigger element is impossible, such as chart points or floating hints during drag.

Virtual anchor follow (chart points)

Month →

Hover any point to see the hint (the tooltip is anchored to that point).

Coordinate follow (mouse move)

Move the mouse inside this area Not following

Triggers

The trigger attribute supports space-separated multi-selection: hover / focus / click / contextmenu / touch (long press) / manual (fully controlled). Defaults to hover focus.

Click trigger

Click trigger

Context menu trigger

Right-click me

Manual trigger

ShowHideControlled trigger

Show / hide delay

open-delay / close-delay control the delay (ms) before showing/hiding on hover, avoiding accidental triggers when moving across quickly.

Open and close delays

300ms delayed show

When moving quickly across multiple triggers, skip-delay-duration (default 300ms) makes the next tooltip skip its open-delay and appear immediately, keeping the interaction responsive.

Delay group (skip-delay-duration)

Hover me (moving from the previous one shows instantly)Then hover me

On touch devices, trigger="touch" shows on long press (touch-delay controls the hold duration, default 500ms).

Touch long-press trigger

Long-press me (touch)

Rich content

The content attribute shows plain text; for rich content (links, icons, multiple lines) use the slot="content" slot. The slot takes precedence over the attribute text.

Rich content slot

Hover for rich contentKey hintCan include a link or icons

Keyboard accessibility

While open, pressing Esc closes the tooltip and restores focus to the trigger; while open, the trigger is linked to the popup via aria-describedby (readable by screen readers).

Esc close + aria-describedby

Focus and press Esc

trigger-keys lets you specify keys (space-separated) that open the tooltip when focused, e.g. trigger-keys="F1".

trigger-keys open

Focus and press F1

Max width

The default max width is 240px (opened via the --oas-tooltip-max-width token); the max-width attribute overrides it (number or CSS length).

Custom max width

max-width=360

Disabled

With disabled, the tooltip never shows (neither hover nor a controlled open).

Disabled

Disabled tooltip

Hoverable popup

interactive keeps the popup open while hovering it (links inside stay reachable).

Interactive popup

Interactive

Offset and collision

offset controls the main-axis distance (default 8px), skidding the cross-axis offset, and collision-padding the viewport-edge avoidance margin (default 4px).

offset / skidding

offset=16skidding=24

collision-padding

collision-padding=20

Color variants

The color attribute supports semantic colors (primary / success / warning / danger), the 11 preset names (e.g. magenta, blue), or any CSS color. All of them go through tokens (with dark variants).

Color variants

primarysuccesswarningdanger

Mount point

append-to mounts the popup into the given container (body or a CSS selector), escaping clipping contexts such as an overflow: hidden ancestor.

append-to body

Mount to body

Auto close

auto-close (ms) closes the tooltip automatically after it opens — useful for onboarding hints.

Auto close

Click, then it auto-closes

Fresh content

fresh is enabled by default: content changes are synced immediately even while closed (reopening always shows the latest). fresh="false" freezes the content while closed.

Fresh content sync

Hover to view (buttons below change the content)Change content

Edge cases

Empty content

Tooltip without content

API

Attributes

AttributeDescriptionTypeDefault
append-toPopup mount point: body or a CSS selector. Moves the popup into an isolated shadow inside the target container (styles stay scoped), escaping clipping contexts such as overflow: hidden / transform; while mounted, ::part(tip) cannot pierce from the host — customize via CSS variables or class selectorsstring
arrowWhether to show the arrow (default true; arrow="false" hides it, the element and ::part(arrow) are kept)stringtrue
arrow-point-at-centerMake the arrow point at the trigger element's center (default points at the trigger's edge; the arrow still points at the anchor center when the panel is shifted by viewport-edge avoidance)boolean
arrow-positionArrow shape: center (default, arrow centered on the panel edge) / merge (only for *-start/*-end placements; a right triangle merges flush with the panel corner — legs collinear with the panel edges, tip pointing orthogonally toward the anchor)stringcenter
auto-adjust-overflowViewport-edge auto flip and avoidance (default true; "false" disables it, keeping the declared placement, which may overflow the viewport)stringtrue
auto-closeAuto-close after opening (ms); 0 or absent disables it
close-delayHide delay (ms, default 0): close after mouseleave/focusout
collision-paddingViewport-edge avoidance margin (px, default 4): the distance kept from the edge when the popup is clamped
colorColor variant: semantic primary/success/warning/danger, one of the 11 preset names (e.g. magenta, blue), or any CSS color. All go through tokens (with dark variants); the arrow background followsstring
contentTooltip content text (the slot="content" rich content takes precedence when present)string
disabledDisabled: the tooltip never shows (neither hover nor a controlled open)boolean
freshContent freshness (default true): content changes are synced immediately even while closed; "false" freezes the content while closed, updating on next openstringtrue
interactiveHoverable popup: moving the mouse into the popup keeps it open (pointer-events: auto), links inside stay reachableboolean
max-widthPopup max width (number in px or CSS length; defaults to the --oas-tooltip-max-width token, 240px)string
offsetMain-axis distance (px, default 8): the gap between the popup and the anchor along the main axis
openControlled display (boolean attribute; shows when present)boolean
open-delayShow delay (ms, default 0): open after mouseenter/focusin; skipped when skip-delay-duration hits
placementPopup placement (12 directions: top/bottom/left/right × start/center/end)Placementtop
skiddingCross-axis offset (px, default 0): top/bottom placements shift horizontally (positive right, negative left); left/right placements shift vertically (positive down, negative up)
skip-delay-durationGlobal delay-group threshold (ms, default 300): when a tooltip closes, the next one opened within this window skips its open-delay and shows immediately (responsive for consecutive hovers); "0" disables it
touch-delayTouch long-press trigger duration (ms, default 500): with touch in trigger, pointerdown held to the threshold opens; releasing/moving out earlier cancels
triggerTrigger modes (space-separated multi-select): hover / focus / click / contextmenu / touch / manual, default hover focus; manual is fully controlledstringhover focus
trigger-keysSpecified keys (space-separated, e.g. F1): pressing one while the trigger is focused opens the tooltipstring
virtualVirtual trigger mode: not bound to a host trigger element; open is fully controlled externally and the position is set by virtual-anchor or virtual-x/virtual-y (for chart points, floating hints during drag)boolean
virtual-anchorAnchor element selector (e.g. #chart-point-1); the tooltip is positioned by that element's rect. Mutually exclusive with virtual-x/virtual-y (coordinates take precedence)
virtual-xVirtual anchor viewport X coordinate (px, e.g. mouse clientX); position by coordinates when set together with virtual-y
virtual-yVirtual anchor viewport Y coordinate (px, e.g. mouse clientY); position by coordinates when set together with virtual-x

Events

EventDescription
oas-open-changeFired when the open state changes (show/hide), detail: { open }

Slots

NameDescription
defaultTrigger element (hover/focus trigger); optional in virtual mode
contentRich content (takes precedence over the content attribute text when present)

oas-open-change: fired when the open state changes (show/hide), detail: { open }. Shown/hidden on hover or focus; role="tooltip", the popup uses pointer-events: none so it never blocks interactions.

Released under the MIT OR Apache-2.0 License.