Search documentation

Find a component or a docs page

Tooltip

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

Usage

Example

The tooltip opens while the pointer rests on the trigger or when the trigger gets keyboard focus. The pointer can move onto the tooltip; it closes when the pointer leaves both, on blur (unless the pointer is still over it), on Escape, or when the trigger is pressed. The trigger's button is described by the tooltip (aria-describedby).

Sides

side: places the tooltip around the trigger: :top (the default), :right, :bottom, :left, or the logical :inline_start and :inline_end, which follow the writing direction. side_offset: is the gap in pixels (4 by default); align: (:start, :center, :end) and align_offset: line it up along that edge. It flips to the other side when there is no room.

With icon

An icon-only trigger still needs an accessible name: the tooltip describes the button, it doesn't name it.

Long content

Long text wraps at 20rem.

Disabled button

A disabled button gets no pointer events, so the wrapper still opens the tooltip on hover.

With keyboard shortcut

Delay and click

delay: waits that many milliseconds of pointer rest before opening (0 by default), close_delay: waits before closing (0 by default, plus a 100 ms grace to cross onto the tooltip). close_on_click: false keeps it open when the trigger is pressed.

Disabled tooltip

disabled: true keeps the tooltip from opening. open: true renders it open on load. Changing the data-ruby-ui--tooltip-open-value or -disabled-value attribute later opens, closes or disables it, and each open or close dispatches ruby-ui--tooltip:change with detail.open.

Installation

Components

ComponentBuilt usingSource
TooltipPhlex
TooltipContentPhlex
TooltipDocsPhlex
TooltipTriggerPhlex
TooltipControllerStimulus JS