MDUIDocs
Copy llms.txt linkCopy llms-full.txt linkView this page in MarkdownDiscuss this page with ChatGPTDiscuss full project docs with ChatGPT
Preset Colors
Custom Color
Extract from Wallpaper
Please select a wallpaper
Getting Started
AI-Assisted Development
Styles
Integration with Frameworks
Components
Avatar Badge BottomAppBar Button ButtonIcon Card Checkbox Chip CircularProgress Collapse Dialog Divider Dropdown Fab Icon Layout LinearProgress List Menu NavigationBar NavigationDrawer NavigationRail Radio RangeSlider Select SegmentedButton Slider Snackbar Switch Tabs TextField Tooltip TopAppBar
Functions
Libraries

Tooltip

Tooltips display supplementary information about a specific element and help explain its function.

Usage

Import the component:

import 'mdui/components/tooltip.js';

Import the TypeScript type:

import type { Tooltip } from 'mdui/components/tooltip.js';

Example:

button
<mdui-tooltip content="Plain tooltip">
  <mdui-button>button</mdui-button>
</mdui-tooltip>

Examples

Plain Text Tooltip

By default, the tooltip displays plain text. The content attribute sets the tooltip content.

Alternatively, use the content slot.

Rich Text Tooltip

For a rich text tooltip, set the variant attribute to rich. The tooltip's title and content can be specified using the headline and content attributes, respectively.

Alternatively, the headline and content slots can be used to specify the tooltip's title and content. The action slot is used to specify the tooltip's action button.

Placement

The placement attribute sets the tooltip's position.

Trigger Method

The trigger attribute sets how the tooltip is triggered.

Open/Close Delay

When the trigger method is hover, the open-delay and close-delay attributes set the opening and closing delays, respectively. The values are in milliseconds.

Disabled State

The disabled attribute disables the tooltip.

API

Properties

AttributePropertyReflectTypeDefault
variantvariant'plain' | 'rich''plain'

Defines the tooltip variant. Default is plain. Possible values:

  • plain: For simple, single-line text.
  • rich: For tooltips with a title, body text, and action buttons.
placementplacement'auto' | 'top-left' | 'top-start' | 'top' | 'top-end' | 'top-right' | 'bottom-left' | 'bottom-start' | 'bottom' | 'bottom-end' | 'bottom-right' | 'left-start' | 'left' | 'left-end' | 'right-start' | 'right' | 'right-end''auto'

Sets the tooltip position. Default is auto. Possible values:

  • auto: Automatically determined. For variant="plain", prefers top; for variant="rich", prefers bottom-right.
  • top-left: Top left.
  • top-start: Top start.
  • top: Top center.
  • top-end: Top end.
  • top-right: Top right.
  • bottom-left: Bottom left.
  • bottom-start: Bottom start.
  • bottom: Bottom center.
  • bottom-end: Bottom end.
  • bottom-right: Bottom right.
  • left-start: Left start.
  • left: Left center.
  • left-end: Left end.
  • right-start: Right start.
  • right: Right center.
  • right-end: Right end.
open-delayopenDelaynumber150

The delay (in milliseconds) before the tooltip appears on hover.

close-delaycloseDelaynumber150

The delay (in milliseconds) before the tooltip disappears on hover.

headlineheadlinestring-

Sets the tooltip title. Only applies when variant="rich". Alternatively, use slot="headline".

contentcontentstring-

Sets the tooltip content. Alternatively, use slot="content".

triggertrigger'click' | 'hover' | 'focus' | 'manual' | string'hover focus'

Defines how the tooltip opens. Multiple space-separated values are supported. Possible values:

  • click: Triggers on click.
  • hover: Triggers on mouse hover.
  • focus: Triggers on focus.
  • manual: Can only be opened and closed programmatically; no other trigger methods can be specified.
disableddisabledbooleanfalse

Disables the tooltip.

openopenbooleanfalse

Opens the tooltip.

Events

Name
open

Emitted when the tooltip starts to open. Can be prevented with event.preventDefault().

opened

Emitted after the tooltip has opened and the animations are completed.

close

Emitted when the tooltip starts to close. Can be prevented with event.preventDefault().

closed

Emitted after the tooltip has closed and the animations are completed.

Slots

Name
(default)

Target element that triggers the tooltip. Only the first element in the default slot is used as the target.

headline

Tooltip title. Only applies when variant="rich".

content

Tooltip content, which can include HTML. If you only need plain text, you can also use the content attribute.

action

Action button at the bottom of the tooltip. Only available when variant="rich".

CSS Parts

Name
popup

Container for the tooltip.

headline

Title of the tooltip.

content

Body text of the tooltip.

action

Action button of the tooltip.

CSS Custom Properties

Name
--shape-corner-plain

Corner radius of the component when variant="plain". You can use a specific pixel value, but it is recommended to reference design tokens.

--shape-corner-rich

Corner radius of the component when variant="rich". You can use a specific pixel value, but it is recommended to reference design tokens.

--z-index

The CSS z-index value of the component.

On this page