Popovers
Simple Popover
Popover is a component which displays a box with a content after a click on an element - similar to the tooltip but can contain more content.
<button type="button" class="btn btn-danger" data-bs-toggle="popover" title="Popover title" data-bs-content="And here's some amazing content. It's very engaging. Right?">Click to toggle popover</button>
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.
<button type="button" tabindex="0" class="btn btn-success" data-bs-toggle="popover" data-bs-trigger="focus" data-bs-content="And here's some amazing content. It's very engaging. Right?" title="Dismissible popover">
Dismissible popover
</button>
Hover
Use the attribute data-bs-trigger="hover"
to show the popover on hovering the element.
<button type="button" tabindex="0" class="btn btn-dark" data-bs-toggle="popover" data-bs-trigger="hover" data-bs-content="And here's some amazing content. It's very engaging. Right?" title="Ohh Wow !">
Please Hover Me
</button>
Four Directions
Four options are available: top, right, bottom, and left aligned.
<!-- Top Position -->
<button type="button" class="btn btn-primary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="top" data-bs-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus." title="">
Popover on top
</button>
<!-- Bottom Position -->
<button type="button" class="btn btn-primary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="bottom" data-bs-content="Vivamus
sagittis lacus vel augue laoreet rutrum faucibus." title="">
Popover on bottom
</button>
<!-- Right Position -->
<button type="button" class="btn btn-primary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="right" data-bs-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus." title="">
Popover on right
</button>
<!-- Left Position -->
<button type="button" class="btn btn-primary" data-bs-container="body" data-bs-toggle="popover" data-bs-placement="left" data-bs-content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus." title="Popover title">
Popover on left
</button>
Disabled Elements
Elements with the disabled
attribute aren’t interactive, meaning users cannot hover or click them to trigger a popover (or tooltip). As a workaround, you’ll want to
trigger the popover from a wrapper <div>
or <span>
and override the pointer-events
on the disabled element.
<span class="d-inline-block" data-bs-toggle="popover" data-bs-content="Disabled popover">
<button class="btn btn-primary" style="pointer-events: none;" type="button" disabled>Disabled button</button>
</span>