Popovers

Documentation and examples for adding Bootstrap popovers, like those found in iOS, to any element on your site.

Overview

  • Zero-length title and content values will never show a popover.
  • Specify container: 'body' to avoid rendering problems in more complex components (like our input groups, button groups, etc).
  • Triggering popovers on hidden elements will not work.
  • Popovers for .disabled or disabled elements must be triggered on a wrapper element.
  • When triggered from anchors that wrap across multiple lines, popovers will be centered between the anchors' overall width. Use .text-nowrap on your <a>s to avoid this behavior.
  • Popovers must be hidden before their corresponding elements have been removed from the DOM.
  • Popovers can be triggered thanks to an element inside a shadow DOM.

Example: Enable popovers everywhere

to initialize all popovers on a page would be to select them by their data-bs-toggle attribute:


var popoverTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="popover"]'))
var popoverList = popoverTriggerList.map(function (popoverTriggerEl) {
  return new bootstrap.Popover(popoverTriggerEl)
})

Example: Using the container option


var popover = new bootstrap.Popover(document.querySelector('.example-popover'), {
 container: 'body'
})

Example

<popover className="btn-danger" popoverContent="And here's some amazing content. It's very engaging. Right?" data-bs-original-title="Popover title" popoverTitle="">Click to toggle popover</popover>

Four directions

Four options are available: top, right, bottom, and left aligned.


<popover className="btn-secondary" popoverContent="Vivamus sagittis lacus vel augue laoreet rutrum faucibus." popoverPlacement="top" data-bs-original-title="" popoverTitle="" tabindex="0">Popover on Top</popover>
<popover className="btn-secondary" popoverContent="Vivamus sagittis lacus vel augue laoreet rutrum faucibus." popoverPlacement="right" data-bs-original-title="" popoverTitle="">Popover on Right</popover>
<popover className="btn-secondary" popoverContent="Vivamus sagittis lacus vel augue laoreet rutrum faucibus." popoverPlacement="bottom" data-bs-original-title="" popoverTitle="">Popover on Bottom</popover>
<popover className="btn-secondary" popoverContent="Vivamus sagittis lacus vel augue laoreet rutrum faucibus." popoverPlacement="bottom" data-bs-original-title="" popoverTitle="">Popover on Left</popover>

Dismiss on next click

Use the focus trigger to dismiss popovers on the user’s next click of a different element than the toggle element.


<a tabindex="0" class="btn btn-lg btn-danger" role="button" data-bs-toggle="popover" data-bs-trigger="focus" title="Dismissible popover" data-bs-content="And here's some amazing content. It's very engaging. Right?">Dismissible popover</a>

var popover = new bootstrap.Popover(document.querySelector('.popover-dismiss'), {
trigger: 'focus'
})

Disabled elements

For disabled class="mt-3"popover triggers, you may also prefer data-bs-trigger="hover focus" so that the popover appears as immediate visual feedback to your users as they may not expect to click on a disabled element.


<span class="d-inline-block" tabindex="0" data-bs-toggle="popover" data-bs-trigger="hover focus" data-bs-content="Disabled popover">
    <button class="btn btn-primary" type="button" disabled>Disabled button</button>
</span>