Live demo#
We use JavaScript similar to the snippet above to render the following live popover. Titles are set via data-bs-title
and body content is set via data-bs-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>
Popover 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>
<!-- 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>
<!-- 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>
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 data-bs-trigger="hover"
trigger Hover to show popover.
<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>
Custom Popovers #
ou can customize the appearance of popovers using CSS variables. We set a custom class with
data-bs-custom-class="primary-popover"
to scope our custom appearance and use it to override some of the
local CSS variables.
<button type="button" class="btn btn-primary" data-bs-toggle="popover" data-bs-placement="top" data-bs-custom-class="primary-popover" data-bs-title="Primary popover" data-bs-content="This popover is themed via CSS variables.">
Primary popover
</button>
<button type="button" class="btn btn-success" data-bs-toggle="popover" data-bs-placement="top" data-bs-custom-class="success-popover" data-bs-title="Success popover" data-bs-content="This popover is themed via CSS variables.">
Success popover
</button>
<button type="button" class="btn btn-danger" data-bs-toggle="popover" data-bs-placement="top" data-bs-custom-class="danger-popover" data-bs-title="Danger popover" data-bs-content="This popover is themed via CSS variables.">
Danger popover
</button>
<button type="button" class="btn btn-info" data-bs-toggle="popover" data-bs-placement="top" data-bs-custom-class="info-popover" data-bs-title="Info popover" data-bs-content="This popover is themed via CSS variables.">
Info popover
</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-trigger="hover" data-bs-content="Disabled popover">
<button class="btn btn-primary" style="pointer-events: none;" type="button" disabled>Disabled button</button>
</span>