Bootstrap4 Tooltip
A tooltip is a small popup window that appears when the mouse moves over an element and disappears when the mouse moves away from the element.
How to create a tooltip
By adding to an elementdata-toggle="tooltip"to create a tooltip.
titleThe content of the attribute is the content displayed in the tooltip:
<a href="#" data-toggle="tooltip" title="I am the tooltip content!">Move the mouse over me</a>
Note:The tooltip should be written in the jQuery initialization code: then on the specified element calltooltip()method.
The following examples can use tooltips anywhere in the document:
Example
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
Try it »
Specify the position of the tooltip
By default, the tooltip is displayed above the element.
You can use thedata-placementattribute to set the direction in which the tooltip is displayed: top, bottom, left or right:
Example
<a href="#" data-toggle="tooltip" data-placement="top" title="I am the tooltip content!">Move the mouse over me</a>
<a href="#" data-toggle="tooltip" data-placement="bottom" title="I am the tooltip content!">Move the mouse over me</a>
<a href="#" data-toggle="tooltip" data-placement="left" title="I am the tooltip content!">Move the mouse over me</a>
<a href="#" data-toggle="tooltip" data-placement="right" title="I am the tooltip content!">Move the mouse over me</a>
Try it »
Use in a button:
Example
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="top" title="Tooltip on top">
Tooltip on top
</button>
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="right" title="Tooltip on right">
Tooltip on right
</button>
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="bottom" title="Tooltip on bottom">
Tooltip on bottom
</button>
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="left" title="Tooltip on left">
Tooltip on left
</button>
Try it »
To add HTML tags to the tooltip content, set data-html="true", and place the content inside the title attribute:
Example
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-html="true" title="<em>Tooltip</em> <u>with</u> <b>HTML</b>">
Tooltip with HTML
</button>
Try it »
Disabled button:
Example
<span class="d-inline-block" tabindex="0" data-toggle="tooltip" title="Disabled tooltip">
<button class="btn btn-primary" style="pointer-events: none;" type="button" disabled>Disabled button</button>
</span>
Try it »
Other extensions