Tooltip
Tooltips display brief contextual information when the user hovers, focuses, or taps a target element.
Point the for attribute at the id of the element the tooltip describes, and Web Awesome wires up positioning and accessibility for you.
Keep tooltips to text and presentational content.
Tooltips can't be reliably focused or operated with a keyboard, so avoid buttons, links, and form controls inside one. Reach for a popover or dropdown when you need interactive content.
Examples
Placement
Use the placement attribute to set the tooltip's preferred position. The actual placement may shift to keep the tooltip inside the viewport.
Triggers
The trigger attribute controls how a tooltip is activated. Pass multiple values separated by a space to combine them — the default is hover focus, which shows the tooltip on pointer hover and keyboard focus.
| Value | Shows the tooltip when |
|---|---|
hover |
The pointer moves over the target |
focus |
The target receives keyboard focus |
click |
The target is clicked; clicking again dismisses it |
manual |
Only when you set open yourself — no built-in activation |
HTML in Tooltips
Use the default slot to add presentational HTML, such as emphasis or line breaks.
Customizing
Use the --max-width custom property to set the width at which the tooltip's content wraps.
Remove the arrow on a single tooltip with the without-arrow attribute.
Resize the arrow on every tooltip with the --wa-tooltip-arrow-size design token. Set it in a :root block after the Web Awesome stylesheet loads — 0 removes arrows globally.
:root { --wa-tooltip-arrow-size: 0; }
Showing & Hiding Manually
Set trigger="manual" and toggle the open attribute to control the tooltip yourself — handy for onboarding hints or surfacing a tooltip in response to your own logic.
API
Importing
If you're using the autoloader or a hosted project, components load on demand — no manual import needed. To cherry-pick a component manually, use one of the following snippets.
Import this component directly from the CDN:
import 'https://ka-f.webawesome.com/[email protected]/components/tooltip/tooltip.js';
After installing Web Awesome via npm, import this component:
import '@awesome.me/webawesome/dist/components/tooltip/tooltip.js';
If you're self-hosting Web Awesome, import this component from your server:
import './webawesome/dist/components/tooltip/tooltip.js';
To import this component for React 18 or below, use the following code:
import WaTooltip from '@awesome.me/webawesome/dist/react/tooltip/index.js';
Slots
Learn more about using slots.
| Name | Description |
|---|---|
| (default) | The tooltip's default slot where any content should live. Interactive content should be avoided. |
Attributes & Properties
Learn more about attributes and properties.
| Name | Description | Reflects |
|---|---|---|
disableddisabled |
Disables the tooltip so it won't show when triggered.
Type
boolean
Default
false
|
|
distancedistance |
The distance in pixels from which to offset the tooltip away from its target.
Type
number
Default
8
|
|
hideDelayhide-delay |
The amount of time to wait before hiding the tooltip when the user mouses out.
Type
number
Default
0
|
|
openopen |
Indicates whether or not the tooltip is open. You can use this in lieu of the show/hide methods.
Type
boolean
Default
false
|
|
placementplacement |
The preferred placement of the tooltip. Note that the actual placement may vary as needed to keep the tooltip
inside of the viewport.
Type
'top'
| 'top-start'
| 'top-end'
| 'right'
| 'right-start'
| 'right-end'
| 'bottom'
| 'bottom-start'
| 'bottom-end'
| 'left'
| 'left-start'
| 'left-end'
Default
'top'
|
|
showDelayshow-delay |
The amount of time to wait before showing the tooltip when the user mouses in.
Type
number
Default
150
|
|
skiddingskidding |
The distance in pixels from which to offset the tooltip along its target.
Type
number
Default
0
|
|
triggertrigger |
Controls how the tooltip is activated. Possible options include
click, hover, focus, and manual. Multiple
options can be passed by separating them with a space. When manual is used, the tooltip must be activated
programmatically.
Type
string
Default
'hover focus'
|
|
withoutArrowwithout-arrow |
Removes the arrow from the tooltip.
Type
boolean
Default
false
|
|
Methods
Learn more about methods.
| Name | Description | Arguments |
|---|---|---|
hide() |
Hides the tooltip | |
show() |
Shows the tooltip. |
Events
Learn more about events.
| Name | Description |
|---|---|
wa-after-hide |
Emitted after the tooltip has hidden and all animations are complete. |
wa-after-show |
Emitted after the tooltip has shown and all animations are complete. |
wa-hide |
Emitted when the tooltip begins to hide. |
wa-show |
Emitted when the tooltip begins to show. |
CSS Custom Properties
Learn more about CSS custom properties.
| Name | Description |
|---|---|
--max-width |
The maximum width of the tooltip before its content will wrap.
|
CSS Parts
Learn more about CSS parts.
| Name | Description | CSS selector |
|---|---|---|
base__arrow |
The popup's exported arrow part. Use this to target the tooltip's arrow. |
::part(base__arrow)
|
base__popup |
The popup's exported popup part. Use this to target the tooltip's popup container. |
::part(base__popup)
|
body |
The tooltip's body where its content is rendered. |
::part(body)
|
tooltip |
The component's outer wrapper. |
::part(tooltip)
|
base |
Deprecated. Use the tooltip part instead. |
::part(base)
|
Dependencies
This component automatically imports the following elements. Sub-dependencies, if any exist, will also be included in this list.