]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
Docs: document delegated tooltips via the selector option mdo/menu-tooltip-docs 42552/head
authorMark Otto <markdotto@gmail.com>
Wed, 24 Jun 2026 22:30:08 +0000 (15:30 -0700)
committerMark Otto <markdotto@gmail.com>
Wed, 24 Jun 2026 22:30:08 +0000 (15:30 -0700)
Add an example initializing one Tooltip on a parent with the selector
option to cover many (and dynamically-added) triggers. Fixes #41020.

site/src/content/docs/components/tooltip.mdx

index 2a5cc65d729d1068aaa51d15a659a1916e695a14..33f0e0d5620c6cfc5d3a7c327afdb246ada98c1e 100644 (file)
@@ -171,6 +171,16 @@ const tooltip = new bootstrap.Tooltip('#example', {
 
 </Callout>
 
+### Delegated tooltips
+
+To enable tooltips on many triggers at once—including elements added to the DOM later—initialize a single instance on a parent element and pass the [`selector` option](#options). Any matching descendant gets a tooltip without re-initializing:
+
+```js
+const tooltip = new bootstrap.Tooltip(document.body, {
+  selector: '[data-bs-toggle="tooltip"]'
+})
+```
+
 ### Via data attributes
 
 <BsTable>