Tooltips
Vue Bootstrap 5 Tooltip component
Documentation and examples for adding custom tooltips with CSS and JavaScript using CSS3 for animations and data-mdb-attributes for local title storage.
Note: Read the API tab to find all available options and advanced customization
Basic example
Overview
Things to know when using the tooltip plugin:
- Tooltips with zero-length
tip
slot values are never displayed. - Triggering tooltips on hidden elements will not work.
-
Tooltips for
.disabled
ordisabled
elements must be triggered on a wrapper element. -
When triggered from hyperlinks that span multiple lines, tooltips will be centered. Use
white-space: nowrap;
on your#reference
slot content to avoid this behavior. - Tooltips must be hidden before their corresponding elements have been removed from the DOM.
- Tooltips can be triggered thanks to an element inside a shadow DOM.
Four directions
Four options are available: top, right, bottom, and left aligned for
direction
property.
And with custom HTML added:
Disabled elements
Elements with the disabled
attribute aren’t interactive, meaning users cannot
focus, hover, or click them to trigger a tooltip (or popover). As a workaround, you’ll want to
trigger the tooltip from a wrapper <div>
or <span>
,
ideally made keyboard-focusable using tabindex="0"
, and override the
pointer-events
on the disabled element.
Tooltips - API
Import
Properties
Property | Type | Default | Description |
---|---|---|---|
arrow |
Boolean | false |
Adds an arrow to a popver element |
boundary |
String | 'clippingParents' |
Overflow constraint boundary of the tooltip (applied only for the preventOverflow modifier of the Popper).
Accepts the values of
'viewport' , 'window' , 'scrollParent' , or an
HTMLElement selector. For more information refer to Popper's
detectOverflow docs.
|
tag |
String | "span" |
Defines tag element wrapping reference slot. |
reference |
String | "" |
Sets custom selector for reference element instead of slot |
popover |
String | " |
Sets custom selector for popover content to be used as tooltip |
options |
Object | Function | {} |
To change Bootstrap's default Popper config, see Popper's configuration |
offset |
String | " |
Offset of the tooltip relative to its target. |
direction |
String | "top |
Position the tooltip relative to its target - top | bottom | left | right. |
maxWidth |
Number | 276 |
Sets max width of the popover element |
Slots
Name | Description | Example |
---|---|---|
reference |
Tooltip triggering action target |
<template #reference><MDBBtn color="danger" size="lg"
@click="tooltip1 = !tooltip1">Click to toggle
tooltip</MDBBtn></template>
|
tip |
Slotted content will be wrapped in a div.tooltip and used as such |
<template #tip>Hi! I'm tooltip</template>
|
[default] |
If you place something within MDBTooltip without specifying slots, it
will be used similarly to the tip slot , yet the content shall still
require wrapping in a div.tooltip .
|
<MDBTooltip><div class="tooltip"> This is a
tooltip</div><template #tip>Hi! I'm
tooltip</template></MDBTooltip>
|
CSS variables
As part of MDB’s evolving CSS variables approach, tolltips now use local CSS variables on
.tooltip
for enhanced real-time customization. Values for the CSS variables
are set via Sass, so Sass customization is still supported, too.