Tooltip

Tooltips display additional information based on a specific action.

A tooltip’s target is its first child element, so you should only wrap one element inside of the tooltip. If you need the tooltip to show up for multiple elements, nest them inside a container first. Tooltips use display: contents so they won’t interfere with how elements are positioned in a flex or grid layout.
Hover Me

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

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

Click to Toggle

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

Toggle Manually
import '@ods/components/web.tooltip';

Note: You only need to import a web component once in your code, as it registers itself globally when defined, allowing you to use it anywhere within your application without needing to re-import it each time you want to use the component.

Slots

NameDescription
(default)The tooltip's target element. Avoid slotting in more than one element, as subsequent ones will be ignored.
contentThe content to render in the tooltip. Alternatively, you can use the `content` attribute.

Properties

Please note, both DOM properties and HTML attributes are shown in the table below. Unless otherwise specified, the property and attribute names are identical.

Property/AttributeReflectsTypeDefault
content
string''
placement
| 'top' | 'top-start' | 'top-end' | 'right' | 'right-start' | 'right-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end''top'
disabled
booleanfalse
distance
number8
open
booleanfalse
skidding
number0
trigger
string'hover focus'
hoist
booleanfalse

Events

React EventDescriptionEvent Detail
ods-showEmitted when the tooltip begins to show.--
ods-after-showEmitted after the tooltip has shown and all animations are complete.--
ods-hideEmitted when the tooltip begins to hide.--
ods-after-hideEmitted after the tooltip has hidden and all animations are complete.--

Methods

NameDescriptionArguments
show()Shows the tooltip.--
hide()Hides the tooltip--

Parts

NameDescription
baseThe component's base wrapper, an `<ods-popup>` element.
base__popupThe popup's exported `popup` part. Use this to target the tooltip's popup container.
base__arrowThe popup's exported `arrow` part. Use this to target the tooltip's arrow.
bodyThe tooltip's body where its content is rendered.

Dependencies

This component automatically imports the following dependencies.

  • ods-popup

Search