Bootstrap Tooltip Showcase — Free Snippet
Bootstrap Tooltip Showcase · Modals · Plain HTML, CSS & JS · Live preview
Copy & paste
Source Code
<div class="container py-5 text-center">
<h1 class="bstip-title">Hover any button</h1>
<p class="text-muted small mb-4">Real Bootstrap tooltips, initialized once in JavaScript from a data attribute.</p>
<div class="d-flex flex-wrap gap-3 justify-content-center">
<button class="btn btn-dark" data-bs-toggle="tooltip" data-bs-placement="top" title="Appears above">Top</button>
<button class="btn btn-dark" data-bs-toggle="tooltip" data-bs-placement="right" title="Appears to the right">Right</button>
<button class="btn btn-dark" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Appears below">Bottom</button>
<button class="btn btn-dark" data-bs-toggle="tooltip" data-bs-placement="left" title="Appears to the left">Left</button>
<button class="btn btn-outline-dark" data-bs-toggle="tooltip" data-bs-html="true" title="<strong>Bold</strong> HTML content">HTML content</button>
<button class="btn btn-primary" data-bs-toggle="tooltip" title="Click me to save your changes">Save</button>
</div>
<p class="text-muted small mt-4">Tooltips initialized: <strong id="bstipCount">0</strong></p>
</div>.bstip-title { font-weight: 800; letter-spacing: -0.01em; }// Bootstrap does not auto-initialize tooltips — every [data-bs-toggle="tooltip"]
// element needs an explicit new bootstrap.Tooltip(el) call, unlike Modal/Collapse/
// Dropdown which wire themselves up automatically from their own data attributes.
const triggers = document.querySelectorAll('[data-bs-toggle="tooltip"]');
const tooltips = [...triggers].map(el => new bootstrap.Tooltip(el));
document.getElementById('bstipCount').textContent = tooltips.length;Extend with AI
Take This Snippet Further With AI
The AI prompt for this one is for Patreon supporters ($3 a month), along with a site with no ads. Supporters enter the passcode once and it is remembered in this browser.
What's included
Features
About this UI Snippet
Bootstrap Tooltip Showcase — HTML, CSS & JavaScript

Most Bootstrap components — Modal, Collapse, Dropdown, Tab — wire themselves up automatically the instant bootstrap.bundle.min.js loads, just from their data-bs-toggle attribute. Tooltip is the one common exception. This snippet shows the full, correct pattern: every element carrying data-bs-toggle="tooltip" still needs an explicit new bootstrap.Tooltip(el) call before it will ever show up, which is the single most common "why doesn't this tooltip work" mistake in real Bootstrap projects.
The six examples cover every cardinal placement (data-bs-placement), a tooltip rendering HTML content via data-bs-html="true" — which requires explicitly opting in, since raw HTML in a tooltip is disabled by default as an XSS precaution — and a tooltip on a primary action button, the most common real-world placement.
Step by step
How to Use
- 1Load the snippetClick the snippet in the sidebar Library tab. The preview loads six buttons and a count of initialized tooltips.
- 2Hover each buttonEach shows Bootstrap's real tooltip in a different placement — top, right, bottom, left.
- 3Hover "HTML content"Its tooltip renders the bold text as actual formatting, not escaped text, because of data-bs-html="true".
- 4Add a tooltip to your own buttonAdd data-bs-toggle="tooltip" and a title attribute to any element, then add it to the JS panel's querySelectorAll selector — or just re-query on load, which already includes it.
Real-world uses
Common Use Cases
Got questions?
Frequently Asked Questions
Bootstrap's Modal, Collapse, Dropdown, and Tab components self-initialize from their data-bs-toggle attribute alone. Tooltip and Popover are the exceptions — the library requires an explicit new bootstrap.Tooltip(element) call per element, by design, since auto-initializing every tooltip on a page could be expensive on content-heavy pages.
Add data-bs-html="true" to the trigger element. Without it, Bootstrap escapes the title content as plain text for security, so any markup would show as literal angle brackets instead of rendering.
Yes — pass a delay option to the constructor, e.g. new bootstrap.Tooltip(el, { delay: { show: 300, hide: 100 } }), instead of the default near-instant show.
Bootstrap tooltips trigger on hover and focus by default, which touch devices approximate via tap-and-hold or focus in some browsers, but the experience is less consistent than on desktop — consider a different pattern (like a Popover on click) for primarily touch-driven interfaces.
Bootstrap renders it as escaped, literal text — you would see the actual angle brackets and tag names in the tooltip instead of formatted content, which is a safe default rather than a silent failure.