Ask any question about Bootstrap here... and get an instant response.
Post this Question & Answer:
How can I customize Bootstrap's tooltip colors using CSS variables?
Asked on May 05, 2026
Answer
To customize Bootstrap's tooltip colors using CSS variables, you can override the default CSS variables that Bootstrap uses for tooltips. This allows you to change the tooltip's background and text color easily.
<!-- BEGIN COPY / PASTE -->
<style>
:root {
--bs-tooltip-bg: #343a40; /* Dark background */
--bs-tooltip-color: #ffffff; /* White text */
}
</style>
<button type="button" class="btn btn-secondary" data-bs-toggle="tooltip" data-bs-placement="top" title="Custom tooltip">
Hover me
</button>
<script>
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl);
});
</script>
<!-- END COPY / PASTE -->Additional Comment:
✅ Answered with Bootstrap 5 best practices.- The `--bs-tooltip-bg` variable sets the tooltip's background color.
- The `--bs-tooltip-color` variable sets the tooltip's text color.
- Ensure your script initializes tooltips after the page content is loaded.
- You can adjust the CSS variables to any color values you prefer.
Recommended Links:
