Bootstrap 4 Tooltips |
To create a tooltip, you have to include data-toggle="tooltip" attribute in your HTML element. For Example,
<button type="button" class="btn btn-danger" data-toggle="tooltip" title="Top">
Top
</button>
The Bootstrap 4 tooltips are not enabled by default, you have to initialize them before you can use it. Follow the below example to initialize the tooltips,
<script> $(function () { $('[data-toggle="tooltip"]').tooltip() }) </script>
Tooltip Buttons
Follow the below example to create a tooltip with button element,
<div class="container">
<h3>
<a href="https://primestudyhub.blogspot.com/search/label/Bootstrap%204" target="_blank">Bootstrap 4 Tooltip Buttons</a></h3>
<hr/>
<button type="button" class="btn btn-primary" data-toggle="tooltip" title="Tooltip Primary Button">
Primary
</button>
<button type="button" class="btn btn-warning" data-toggle="tooltip" title="Tooltip Warning Button">
Warning
</button>
<button type="button" class="btn btn-danger" data-toggle="tooltip" title="Tooltip Danger Button">
Danger
</button>
<button type="button" class="btn btn-secondary" data-toggle="tooltip" title="Tooltip Secondary Button">
Secondary
</button>
</div>
Demo
Tooltip Links
Follow the below example to create a tooltip with a link, <nav class="nav">
<a class="nav-link active" target="_blank" data-toggle="tooltip" href="https://primestudyhub.blogspot.com/search/label/Bootstrap%204" title="Tooltip Link">Active</a>
<a class="nav-link" href="https://primestudyhub.blogspot.com/search/label/Bootstrap%204" target="_blank" data-toggle="tooltip" title="Tooltip Link">Link</a>
<a class="nav-link" href="https://primestudyhub.blogspot.com/search/label/Bootstrap%204" target="_blank" data-toggle="tooltip" title="Tooltip Link">Link</a>
<a class="nav-link disabled" href="https://primestudyhub.blogspot.com/search/label/Bootstrap%204" target="_blank" data-toggle="tooltip" title="Tooltip Link">Disabled</a>
</nav>
Demo
Tooltip Positions
Follow the below example to create a tooltip with different positions,<div class="container">
<h3>
<a href="https://primestudyhub.blogspot.com/search/label/Bootstrap%204" target="_blank">Bootstrap 4 Tooltip Positions</a></h3>
<hr/>
<button type="button" class="btn btn-primary" data-toggle="tooltip" data-placement="top" title="Tooltip on top">
Top
</button>
<button type="button" class="btn btn-warning" data-toggle="tooltip" data-placement="right" title="Tooltip on right">
Right
</button>
<button type="button" class="btn btn-danger" data-toggle="tooltip" data-placement="bottom" title="Tooltip on bottom">
Bottom
</button>
<button type="button" class="btn btn-secondary" data-toggle="tooltip" data-placement="left" title="Tooltip on left">
Left
</button>
</div>
Comments