<x-widget.tooltip>
Tooltip Blade component for Laravel and Livewire
A short label or hint on an element, shown when the pointer rests on it or it gets keyboard focus, and on a touch screen by a tap on plain text or a long press on a button, above the finger; hidden on Esc. On any side, moving to the other when there's no room, and never clipped by a table or a modal. Read out by screen readers as the element's description. Works inside Livewire components.
php artisan bladewell:add tooltip
- Also adds
- Icon
- Works with
- Laravel 12 and 13, Livewire 3 and 4, Tailwind CSS 4.1+, PHP 8.3+
Usage
Livewire
Inside a Livewire component a tooltip's text updates with each render, and it stays linked to its element for screen readers. Wrap the element, not the component's root.
<x-widget.tooltip :text="$synced ? 'Synced '.$syncedAt->diffForHumans() : 'Not synced yet'">
<x-widget.button variant="neutral" icon="refresh-cw" label="Sync now" wire:click="sync" />
</x-widget.tooltip>
Examples
Placement
placement is top (the default), bottom, start or end; start and end follow the page's direction. Without room on that side it moves to the opposite one. On a touch screen, a tooltip a finger opens goes on top instead, where the finger doesn't cover it.
Show code Hide code
<div class="flex flex-wrap gap-3">
@foreach (['top', 'bottom', 'start', 'end'] as $side)
<x-widget.tooltip :text="'On the '.$side" :placement="$side">
<button type="button" class="bg-field hover:bg-line focus-visible:ring-primary rounded-xl px-4 py-2.5 text-sm font-medium outline-none focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:ring-offset-surface">{{ ucfirst($side) }}</button>
</x-widget.tooltip>
@endforeach
</div>
On text
Around something that can't take focus (an icon, a word), the tooltip makes it focusable, so keyboard users reach it too, and an icon with no text of its own is named by the tooltip. Keep it to text that adds to what's there; don't hide what someone needs in it.
Last synced 2 minutes ago
Show code Hide code
<p class="text-sm">
Last synced 2 minutes ago
<x-widget.tooltip text="Syncs every 5 minutes while the app is open" placement="end" class="align-middle">
<x-widget.icon name="info" class="text-foreground/70 size-4" />
</x-widget.tooltip>
</p>
Props
Other attributes, such as autocomplete or data-*, are passed through to the element. class styles the component's outer wrapper.
<x-widget.tooltip>
| Prop | Default | Description |
|---|---|---|
| text | Required | What it says: a few words that name or explain what it's on ("Copy link", "Last synced 2 minutes ago"). |
| placement |
'top'
|
Which side of it the tooltip goes: top (the default), bottom, start or end. It moves to the opposite side when there's no room. |
| id |
null
|
Defaults to one made for it; the element inside points at it with aria-describedby. |
Accessibility
All 3 examples above are checked with axe-core against the WCAG 2.2 A and AA rules, in the light theme and the dark one, both as the page draws and with each popover, dialog, toast and tooltip opened, on every change. A change that fails can't be merged. Where axe can't decide, such as contrast on SVG text, the test measures the colours itself instead of letting it pass.
Automated checks can't judge everything: how it sounds in a screen reader, and how it feels to use from the keyboard, still need a person. Check those on your own pages too.
Source
What bladewell:add tooltip writes to your app with the default namespaces. Prefer to copy by hand? Take these files, plus the ones from
the components it also adds , and the theme and base CSS.
resources/views/components/widget/tooltip/index.blade.php Show
resources/js/widget/tooltip/index.js Show
app/View/Widget/ElementIds.php Show