Tooltip

<wa-tooltip> Stable Since 2.0

Tooltips display brief contextual information when the user hovers, focuses, or taps a target element.

A tooltip's target is based on the for attribute which points to an element id.

This is a tooltip Hover Me

Examples

Link to This Section

Placement

Link to This Section

Use the placement attribute to set the preferred placement of the tooltip.

top-start top top-end left-start right-start left right left-end right-end bottom-start bottom bottom-end

Click Trigger

Link to This Section

Set the trigger attribute to click to toggle the tooltip on click instead of hover.

Click to Toggle Click again to dismiss

Manual Trigger

Link to This Section

Tooltips can be controller programmatically by setting the trigger attribute to manual. Use the open attribute to control when the tooltip is shown.

Toggle Manually This is an avatar!

Removing Arrows

Link to This Section

You can control the size of tooltip arrows by overriding the --wa-tooltip-arrow-size design token. To remove the arrow, use the without-arrow attribute.

No Arrow This is a tooltip with no arrow

To override it globally, set it in a root block in your stylesheet after the Web Awesome stylesheet is loaded.

:root {
  --wa-tooltip-arrow-size: 0;
}

HTML in Tooltips

Link to This Section

Use the default slot to create tooltips with HTML content. Tooltips are designed only for text and presentational elements. Avoid placing interactive content, such as buttons, links, and form controls, in a tooltip.

Hover me
I'm not just a tooltip, I'm a tooltip with HTML!

Setting a Maximum Width

Link to This Section

Use the --max-width custom property to change the width the tooltip can grow to before wrapping occurs.

This tooltip will wrap after only 80 pixels. Hover me

Importing

Link to This Section

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.

CDN npm Self-Hosted React

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

Link to This Section

Learn more about using slots.

Attributes & Properties

Link to This Section

Learn more about attributes and properties.

Methods

Link to This Section

Learn more about methods.

Events

Link to This Section

Learn more about events.

CSS custom properties

Link to This Section

Learn more about CSS custom properties.

CSS parts

Link to This Section

Learn more about CSS parts.

Dependencies

Link to This Section

This component automatically imports the following elements. Sub-dependencies, if any exist, will also be included in this list.

Need a hand? Report a bug Ask for help
    No results