Skip to main content
Copy for LLM

Tooltip

The <x-wirekit::tooltip> component shows contextual information on hover, focus, and long-press (touch). Positioned via Floating UI with automatic flip/shift.

Tooltips should never be the only source of critical information. For essential details, use visible labels or hint text. On touch devices, tooltips are triggered by long-press (500ms).

Usage

Text Tooltip

Text Tooltip

Rich Content Tooltip

Rich Content

Components in the content take the panel's text color, as they do on any filled surface: a text, heading or link inside reads in the tooltip's color. With surface="elevated" the panel is a surface of the page, and its content keeps the page's colors.

Inside a Paragraph

A tooltip roots in a <div>, and a <div> is not allowed inside a <p>. Pass as="span" and both the wrapper and the trigger root in a <span> instead, so the tooltip stays part of the sentence it belongs to.

Inside a Paragraph

Your plan renews monthly. Cancel any time.

A Keyboard Shortcut

A tooltip draws the shortcut of the control in its slot after its text, read from the control's x-wk-shortcut, as a kbd draws it: ⌘ S on a Mac and Ctrl S elsewhere. shortcut names one the control does not bind itself, and :shortcut="false" draws none:

{{-- 1. "Save", then ⌘ S or Ctrl S, read from the button. --}}
<x-wirekit::tooltip text="Save">
    <x-wirekit::button x-wk-shortcut="cmd+s" wire:click="save">Save</x-wirekit::button>
</x-wirekit::tooltip>

{{-- 2. A shortcut registered with window.wirekitShortcut(), named on the tooltip. --}}
<x-wirekit::tooltip text="Next order" shortcut="j">
    <x-wirekit::button icon-only aria-label="Next order"><x-slot:iconLeft><x-wirekit::icon name="arrow-down" size="sm" aria-hidden="true" /></x-slot:iconLeft></x-wirekit::button>
</x-wirekit::tooltip>

Under rich content the shortcut stands on a line of its own. A single-key shortcut such as j is drawn only while single keys work, so the tooltip never offers a key that is switched off. A screen reader hears the keys the panel shows, open or closed: those of the reader's platform, and a single key only while single keys work.

Width & Layout

Plain-text tooltips (text prop) auto-size to their content with a max-width for readability. Rich tooltips (slot content) size to their content — add explicit widths if needed:

<x-wirekit::tooltip>
    <x-slot:content>
        <div class="w-64">Wider tooltip with more detailed content.</div>
    </x-slot:content>
    <x-wirekit::button intent="neutral" size="sm">Details</x-wirekit::button>
</x-wirekit::tooltip>

The tooltip ends where the control in its slot ends. A button, a link or a field stands at the top of the trigger's line rather than on its baseline, so a tooltip around an icon button adds nothing below it, and a row of such buttons lines up on its middle.

Placement

Control where the tooltip appears relative to its trigger:

Tooltip placements

Available placements: top, top-start, top-end, bottom, bottom-start, bottom-end, left, left-start, left-end, right, right-start, right-end.

A side of the line follows the page instead: start, start-start, start-end, end, end-start and end-end. end opens on the right of a page that reads from the left and on the left of one that reads from the right, and start the other way round, so a tooltip beside a rail or a list keeps facing the content when the page reads from the right.

Surface

A tooltip is inverted by default: its background takes the text color and its text takes the page color, so it stands out on a light theme and on a dark one alike. surface="elevated" gives it the surface menus and popovers use instead, the elevated background with the body text and the theme's border.

Tooltip surfaces — hover each button

The elevated surface draws its edge from --border-wk-width and --color-wk-border, the way a popover does. On a theme that removes borders and shadows, such as Minimal, it sets itself apart from the page by its background alone, as the theme's menus do.

Styling Variants

The tooltip's surface, text color, border radius, and opacity all derive from CSS variables — override them per-tooltip via inline style (scopes to the trigger wrapper) or globally via theme :root. Hover each button below to see a different style applied without changing the component itself.

Tooltip styling variants — hover each button

Per-tooltip overrides win because the inline style cascades onto the hover-trigger wrapper, which the tooltip panel reads via var(--color-wk-tooltip-*). For an app-wide tooltip palette change, set the same tokens on :root {} in app.css instead of per-instance.

Custom Delays

Control how quickly tooltips appear and disappear. In the preview below, the left button shows instantly and hides slowly; the right button waits before showing and hides quickly:

Custom delays

Trigger Behavior

Device Show Trigger Hide Trigger Auto-Dismiss
Mouse (desktop) mouseenter + delay mouseleave + delay No
Keyboard focusin, when the focus is visible (:focus-visible) focusout No
Touch Long-press (500ms) Finger release Yes, after 1500ms

Theming

Tooltips use inverted colors — dark background on light mode, light background on dark mode. The tokens that do it, and everything else the tooltip reads, are in Design Tokens below.

Behavior

  • Floating UI (bundled) positions the tooltip with automatic flip and shift
  • Transitions use opacity fade for smooth show/hide
  • Livewire SPA navigation closes open tooltips
  • Touch devices use long-press (500ms) to trigger, auto-dismiss after 1.5s
  • Focus from a script does not open it. A tooltip opens on focus only when the browser draws that focus (:focus-visible), which is the focus a keyboard gives. A dialog focusing its first control when it opens, after a click, shows no tooltip; tabbing to the same control does. A mouse still gets the tooltip on hover
  • Inside a dialog it stands above the dialog. A tooltip whose trigger is in a modal or a drawer is lifted over that dialog's layer, and so is a dropdown or a popover opened from inside one

Switching a Tooltip Off

A tooltip on a control that has become inert should go quiet. disabled does that:

A tooltip that is switched off

pointer-events: none on the wrapper is not a way to do this, however much it looks like one. mouseenter is delivered to every ancestor of the element the pointer actually hit, whatever those ancestors' own pointer-events value — so the handler still fires and the panel still appears, over a control that is supposed to be dead.

Switched off, the tooltip is quiet for a screen reader as well. It describes its trigger with nothing, and around a control the keyboard does not reach, such as the disabled button above, it makes no stop of its own, since there is nothing to show on focus. focusable-trigger still makes one where it is set.

Following live state

The prop answers for the render that produced it. When the answer changes while the page is open — a sidebar collapses, a row enters a loading state — bind the attribute the component reads instead. No extra prop is involved; it is the same switch, read at the moment the tooltip would open:

{{-- 1. `quiet` is your own Alpine state — anything reactive works. --}}
<div x-data="{ quiet: true }">
    {{-- 2. The component reads this attribute when a hover or focus would open
            the panel, so it follows the value rather than a snapshot of it. --}}
    <x-wirekit::tooltip text="Only while the row is idle"
        x-bind:data-wk-tooltip-disabled="quiet ? 'true' : 'false'">
        <x-wirekit::button intent="neutral">Retry</x-wirekit::button>
    </x-wirekit::tooltip>

    {{-- 3. Nothing re-renders and nothing re-initializes when this flips. --}}
    <x-wirekit::button x-on:click="quiet = false">Allow it</x-wirekit::button>
</div>

The bound switch also takes the description off the control while it is on and gives it back once it is off, so a screen reader hears the tip when it would show.

One Panel for the Page

Every tooltip carries its panel in its markup, hidden until it opens. On a form with help on every label, that is one panel per field, and the help text stands twice: once in the panel and once in the hidden text the field is described by.

With shared, a tooltip of words alone draws into one panel the page's tooltips share. Its words stand once, in an element its trigger is described by, and the shared panel shows them while the tooltip is open. Hover, focus, a long press, Escape and the placement behave as with a panel of its own. A tooltip with a content slot, a shortcut or the words of a cut text keeps its own panel, which draws them.

With describes off, nothing is described by the words, so the tooltip writes no element for them and keeps them on its trigger. A link whose name the tooltip repeats, such as an item of an app rail, then holds that name once in the page, and a browser test that looks for it by its text finds one element.

<x-wirekit::tooltip text="Shown in the order confirmation" shared>
    <x-wirekit::icon name="info" aria-label="About this field" />
</x-wirekit::tooltip>

To turn it on for every tooltip, the help on labels included, set the default in config/wirekit.php:

'components' => [
    'tooltip' => ['shared' => true],
],

text-from names an element on the page that already holds the words, by its id. A shared tooltip is described by that element and shows its words, so they are not written again. The help on a field's label passes the hidden help text the field is described by.

A shared tooltip around words or a figure, with no button or link of yours inside it, renders as one element. The trigger is its own tab stop and carries its description, and one script on the page drives every such trigger, so a table with a tooltip in every row writes no component for each of them. A status dot with shared is its own trigger in the same way. Around a control of yours the tooltip keeps its component, which puts the description on that control once the page has started.

Sizes whose SKU shows in the shared panel
Color S M L
Blue 12 40 7

Building the Panel When It Is Needed

A tooltip with a panel of its own builds that panel with the page, and the panel starts its script, though most tooltips never show. With lazy, a tooltip keeps its panel in a <template> until it first shows. Once built, the panel stays when the tooltip hides again, and it shows as a panel built with the page does.

The trigger is described from the start all the same. Before the panel is built, aria-describedby has no panel to name, and a build as the focus lands would race the screen reader that reads the description at that moment. So a lazy tooltip writes its words once more, hidden beside the trigger: its text, or the words a screen reader reads from its content slot, followed by the keys of its shortcut. The trigger is described by them before the panel is built and after.

{{-- 1. The panel is built the first time the tooltip shows; the button is described from the start --}}
<x-wirekit::tooltip text="Save the draft" lazy>
    <x-wirekit::button x-wk-shortcut="cmd+s" wire:click="save">Save</x-wirekit::button>
</x-wirekit::tooltip>

To build every tooltip this way, set it once in the components array of config/wirekit.php:

// config/wirekit.php
'components' => [
    'tooltip' => ['lazy' => true],
],

A tooltip of words alone can draw into the page's one panel instead, which has nothing to build: see One Panel for the Page. A shared tooltip leaves lazy aside.

Until a tooltip has shown, its panel is not part of the page: a script that looks for something inside it, and a browser test that reads it before the tooltip shows, find nothing. Show the tooltip first, or leave lazy off for a tooltip whose panel something has to find while it is hidden.

Props

Prop Type Default Description
text string|null null Plain-text tooltip content
placement string 'top' Floating UI placement, or a side of the line, start or end, that follows the page
offset int 6 Distance in px between trigger and tooltip
delay-show int 300 Delay in ms before showing (desktop hover)
delay-hide int 100 Delay in ms before hiding (desktop mouseleave). This is the window the pointer uses to cross the offset gap onto the panel, so a value too small to make that trip gives up the hoverable half of WCAG 1.4.13 — see the warning under Accessibility
focusableTrigger bool|null null Whether the trigger is a tab stop of its own, so the tooltip shows on focus and not just on hover (WCAG 2.1.1). null decides from the slot: around a button, a link or a field the reader already reaches, the trigger stays out of the tab order and that control's focus shows the tooltip, and so it does around a button or a field that tabindex="-1" leaves to the arrow keys of its toolbar; around an icon, a word or a disabled button, the trigger is the stop. true and false override the choice. The stop is a button that Enter and Space open; a stop forced with true around a control that takes the focus itself takes no role, since it would nest one control in another.
describes bool true Link the tooltip to its trigger through aria-describedby. Where the slot names its control with the tooltip's words, as its text or its aria-label, the link is left out on its own, so a screen reader does not read the name twice; a shortcut drawn after the words keeps it. Set false when the name comes from elsewhere, such as an aria-labelledby or an aria-label that Alpine binds.
disabled bool false Switch the tooltip off without removing it. See below for the live form.
shortcut string|false|null null A keyboard shortcut drawn after the text, for the reader's platform. Unset, the one the control in the slot binds with x-wk-shortcut; false draws none. One the grammar does not read is reported through strict validation, and none is drawn. See A Keyboard Shortcut
surface 'inverted'|'elevated' 'inverted' The panel's surface: the inverted default, or the elevated surface menus and popovers use. See Surface. An invalid value is reported through strict validation and falls back to 'inverted'
shared bool false Draw into the one panel the page's tooltips share, for a tooltip of words alone. components.tooltip.shared in config/wirekit.php sets the default, and the rows of a sidebar that can collapse read components.sidebar.item.shared-tooltip first. See One Panel for the Page
text-from string|null null The id of an element that holds the tooltip's words already. A shared tooltip is described by it and shows its words instead of writing them again
lazy bool false Keep the panel out of the page until the tooltip first shows; the trigger is described from the start by the tooltip's words, hidden beside it. components.tooltip.lazy in config/wirekit.php sets the default, and a shared tooltip leaves it aside. See Building the Panel When It Is Needed
scope string|null null Scoped personalization key
as string 'div' The element the wrapper and the trigger root in. Set as="span" to use a tooltip inside a text-level component — see Pitfalls.

Slots

Slot Purpose
default The trigger element (hovered/focused to show tooltip)
content Rich HTML tooltip content (alternative to text prop)

Accessibility

  • Trigger: aria-describedby="{tooltipId}"
  • A trigger the tooltip makes a tab stop of its own, around an icon, a word or a disabled control, is a role="button": Enter or Space shows the tooltip, as a toggletip does. Its words name it; around an icon alone the tooltip's text names it, and the description is left off so a screen reader does not read the text twice. Around a disabled control it carries aria-disabled="true", so the reader hears that the control is unavailable and then why. An aria-label or aria-labelledby of yours names it first
  • Tooltip: role="tooltip", matching id
  • Unique ID generated per tooltip instance
  • The panel is hoverable: moving the pointer from the trigger onto the tip keeps it open, so a long tip can be read at high zoom or with an unsteady hand. The delay-hide window is what bridges the offset gap between the two — setting delay-hide="0" switches that behavior off, because the panel closes before the pointer arrives.
  • The panel is dismissible with Escape from anywhere on the page, whether the tooltip was opened by hovering or by focusing. A pending delay-show is canceled too, so a tip cannot appear just after the key that dismissed it.

Together those two are WCAG 1.4.13 (Content on Hover or Focus, AA); the third clause, persistent, is met by the tip staying up until the pointer or focus leaves, Escape is pressed, or the developer switches it off.

delay-hide="0" gives up the hoverable half of 1.4.13

The panel closes on mouseleave before the pointer can cross the offset gap to reach it, so a tip that takes more than a glance to read cannot be read at all — at 200% zoom, or with an unsteady hand, it is gone by the time the pointer arrives. Avoid 0 whenever the tip carries text rather than a one-word label.

WireKit does not clamp the value, and that is deliberate: the prop stays yours. What goes with it is the AA claim above, so make it a decision rather than a default you inherited from an example.

Keyboard Interaction

Key Action
Tab (focusing the trigger) Show the tooltip
Tab (away from trigger) Hide the tooltip
Enter / Space (on a trigger the tooltip made a stop of its own) Show the tooltip, also after Escape hid it
Escape Hide the tooltip, and cancel one that is about to open. Works wherever focus is — a tooltip opened by hovering is dismissed without moving the pointer. A modal or a drawer around it stays open

Pitfalls

  • Don't put interactive content inside a tooltip. Tooltips are descriptive — buttons, links, and form controls inside them are not reachable by keyboard. The panel does take pointer events (that is what makes it hoverable), so a control placed there would be clickable with a mouse and unreachable without one, which is worse than one that plainly does not work. Use <x-wirekit::popover> or <x-wirekit::hover-card> instead.
  • Inside a paragraph, set as="span". The wrapper and the trigger root in a <div> by default, and a <div> inside a <p> is invalid HTML — the browser closes the paragraph and lifts the tooltip out of it. The trigger then stops being a child of its text and becomes its sibling, which in a grid gives it a cell of its own and lands it next to the wrong row. Nothing reports this: the markup is all present, and the only symptom is where the tooltip sits on screen. So whenever the tooltip sits inside <x-wirekit::text> or any other element that holds phrasing content, pass as="span".
  • And only when the slot is phrasing content too. as="span" is invalid in the other direction if the slot carries a block element, so it stays opt-in rather than the default. Wrap an icon, a word or a short label; keep as="div" for anything with a block inside.
  • Don't use a tooltip as the primary label. Touch users have no hover, and screen readers don't announce tooltip content reliably across browsers. The visible label must stand on its own.

Design Tokens

Token Used for
--font-wk-sans Tooltip font family
--text-wk-sm Tooltip font size
--color-wk-tooltip-bg Tooltip background — defaults to the text color, which is what inverts it
--color-wk-tooltip-text Tooltip text — defaults to the background color
--radius-wk-sm Border radius
--shadow-wk-md Drop shadow
--size-wk-tooltip-max Maximum width (default 20rem)
--padding-wk-x-sm / --padding-wk-y-xs Padding
--z-wk-tooltip Stacking context (default 60)

Customization

All four timing and placement props read a project-wide default, so a house tooltip style is set once rather than on every call site:

// config/wirekit.php
'components' => [
    'tooltip' => [
        'placement' => 'top',
        'offset' => 6,
        'delay-show' => 300,
        'delay-hide' => 100,
    ],
],

The two delays are in milliseconds and the offset in pixels. Note the kebab-case keys — delay-show in the file, delay-show on the tag, $delayShow inside the component.

Do not set delay-hide to zero

The hide delay is what makes the tooltip hoverable: it is the window in which the pointer can travel from the trigger onto the panel without the panel disappearing. WCAG 2.1 SC 1.4.13 (Content on Hover or Focus) requires exactly that, and setting it here switches it off for every tooltip in the application at once — which is why the value belongs in review rather than in a quick config edit. See the Pitfalls above.

Usage & Conventions

Need a click-triggered hint? A tooltip is hover/focus only by design (the WAI-ARIA tooltip pattern). For a "click the ? icon to reveal a note" affordance — or any content with buttons, links, or form fields — use Popover (click-toggled, full focus management). For rich content that previews on hover, use Hover Card.

Text cut off with an ellipsis? <x-wirekit::text truncate="tooltip"> shows the whole text in this tooltip while, and only while, the text is cut. See Truncation With a Tooltip.

Further Reading

Updated in WireKit v2.74.0 (2026-11-24)

Was this page helpful?

Thank you for your feedback!

Voting requires cookies or local storage. What we store