Tooltip

Display prompt information for mouse hover.

Basic usage

Tooltip has 9 placements.

Use attribute content to set the display content when hover. The attribute placement determines the position of the tooltip. Its value is [orientation]-[alignment] with four orientations top, left, right, bottom and three alignments start, end, null, and the default alignment is null. Take placement="left-end" for example, Tooltip will display on the left of the element which you are hovering and the bottom of the tooltip aligns with the bottom of the element.

Theme

Tooltip has two built-in themes: dark and light.

TIP

To use customized theme, you will have to known where your tooltip is rendered into, if your tooltip is rendered into the root element, you will need to set the css rule globally.

It is recommended that not using linear gradient background color when you using customized theme and showing the arrow at the same time, because the popup arrow and the content are two different elements, the popup arrow's style needs to be set individually, and when it comes to the gradient background color, it might seem a little bit weird.

Set effect to modify theme, and the default value is dark.

More Content

Display multiple lines of text and set their format.

Override attribute content of b-tooltip by adding a slot named content.

Advanced usage

In addition to basic usages, there are some attributes that allow you to customize your own:

transition attribute allows you to customize the animation in which the tooltip shows or hides, and the default value is b-fade-in-linear.

disabled attribute allows you to disable tooltip. You just need set it to true.

In fact, Tooltip is an extension based on Popper, you can use any attribute that are allowed in Popper.

TIP

The router-link component is not supported in tooltip, please use vm.$router.push.

Disabled form elements are not supported for Tooltip, more information can be found at MDNopen in new window. You need to wrap the disabled form element with a container element for Tooltip to work.

HTML as content

The content attribute can be set to HTML string.

WARNING

Although content property supports HTML strings, dynamically rendering arbitrary HTML on your website can be very dangerous because it can easily lead to XSS attacksopen in new window. So when raw-content is on, please make sure content is trusted, and never assign user-provided content.

Virtual triggering

Sometimes we want to render the tooltip on some other trigger element, we can separate the trigger and the content.

TIP

Virtual triggering tooltip is controlled component, so that you will have to control the visibility of the tooltip your own when this happens, YOU WILL NOT be able to close the tooltip by clicking somewhere else.

Singleton

Tooltip can also be singleton, which means you can have multiple trigger with only one tooltip instance, this function is implemented based on Virtual triggering

TIP

Known issue: when using singleton, the popup will be bouncing out from unexpected places

Controlled

Tooltip can be controlled by the parent component, by using :visible you can implement two way binding.

Animations

Tooltip can be customized animated, you can set the the desired animation function as you desired.

Attributes

NameDescriptionTypeAccepted ValuesDefault
append-towhich element the tooltip CONTENT appends toCSSSelector | HTMLElement—#b-popper-container-[randomValue]
effectTooltip theme, built-in theme: dark / lightstringstringdark
contentdisplay content, can be overridden by slot#contentString——
raw-contentwhether content is treated as HTML stringboolean—false
placementposition of Tooltipstringtop/top-start/top-end/bottom/bottom-start/bottom-end/left/left-start/left-end/right/right-start/right-endbottom
visible / v-model:visiblevisibility of Tooltipboolean—false
disabledwhether Tooltip is disabledboolean—false
offsetoffset of the Tooltipnumber—0
transitionanimation namestring—b-fade-in-linear
popper-optionspopper.jsopen in new window parametersObjectrefer to popper.jsopen in new window doc{modifiers: [{name: 'computeStyles',options: {gpuAcceleration: false}}]}
show-afterdelay of appearance, in millisecondnumber—0
show-arrowwhether the tooltip content has an arrowbooleantrue / falsetrue
hide-afterdelay of disappear, in millisecondnumber—200
auto-closetimeout in milliseconds to hide tooltipnumber—0
manualwhether to control Tooltip manually. mouseenter and mouseleave won't have effects if set to trueboolean—false
popper-classcustom class name for Tooltip's popperstring——
enterablewhether the mouse can enter the tooltipBoolean—true
tabindextabindexopen in new window of Tooltipnumber—0
teleportedwhether tooltip content is teleported, if true it will be teleported to where append-to setsbooleantrue / falsetrue
triggerHow should the tooltip be triggered (to show)stringhover / click / focus / contextmenuhover
virtual-triggeringIndicates whether virtual triggering is enabledboolean—false
virtual-refIndicates the reference element to which the tooltip is attachedHTMLElement——
trigger-keysWhen you click the mouse to focus on the trigger element, you can define a set of keyboard codes to control the display of tooltip through the keyboardArray—['Enter','Space']

Slots

NameDescription
—Tooltip triggering & reference element
contentcustomize content
Last Updated:
Contributors: Tam Mai