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;Bootstrap Tooltip Showcase — Free Snippet
Bootstrap Tooltip Showcase · Buttons · Plain HTML, CSS & JS · Live preview
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.
Build with AI
Build, Understand, Optimize, and Extend It With AI
Hand this snippet's HTML, CSS, and JS to an AI coding assistant like Claude and ask it to add a custom delay and animation duration, or to build a small reusable helper function that auto-initializes every tooltip on a page including ones added dynamically later. It's also a good exercise to ask the assistant to explain Popper.js's role in Bootstrap's Tooltip and Popover positioning.
Prompt to recreate it
Copy this into your AI assistant of choice to build the effect from scratch, or as a jumping-off point for your own variant:
Build a Bootstrap 5.3 tooltip showcase, using the real Bootstrap CDN framework (bootstrap.min.css and bootstrap.bundle.min.js), not custom CSS made to resemble Bootstrap.
Requirements:
- At least four buttons, each with data-bs-toggle="tooltip" and a title attribute, one for each of Bootstrap's cardinal placements via data-bs-placement (top, right, bottom, left).
- One additional button demonstrating an HTML-content tooltip using data-bs-html="true" with bold or otherwise formatted text in its title.
- In JavaScript, explicitly initialize every tooltip trigger with new bootstrap.Tooltip(element) — do not rely on automatic initialization, since Bootstrap's Tooltip component requires this explicit step unlike Modal or Dropdown.
- Display a count of how many tooltip instances were successfully initialized, to make the explicit-initialization step visibly confirmed rather than just assumed.Want to tighten it up first? Run this prompt through the AI Prompt Studio to score it across 8 quality dimensions, catch anti-patterns, and tune the wording for Claude, ChatGPT, or Gemini before you paste it in.
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.