Components
Popovers
Click-to-open bubbles with a title and body — a native popover anchored to its button.
How it works
A popover is a <div class="popover" popover> with an id. Any
<button popovertarget="id"> toggles it. The browser puts it in the top layer, closes it on
a click outside or Escape, and treats the invoking button as the popover's implicit anchor — so CSS
anchor positioning can place the bubble next to the button without any coordinates.
- Baseline: Popover API (Chrome 114, Safari 17, Firefox 125). Without anchor positioning the popover is centered in the viewport and the arrow is hidden.
- Enhancement: CSS anchor positioning (
position-area) puts it on the side named bydata-bs-placementand flips it when there is no room. - Enhancement:
.fadeanimates the opacity in with@starting-style. - Fallback: none beyond the baseline. A popover needs the Popover API; for hover text that works everywhere use a tooltip.
data-bs-placement lives on the .popover element, not the button. It is the only
data-bs-* attribute the popover CSS reads. Bootstrap's data-bs-toggle="popover",
data-bs-content and title attributes do nothing here — the content is real markup.Live demo
Popover title
HTML
<button type="button" class="btn btn-danger" popovertarget="popovers-demo">Click to toggle popover</button>
<div class="popover fade" popover id="popovers-demo" data-bs-placement="end">
<div class="popover-arrow"></div>
<h3 class="popover-header">Popover title</h3>
<div class="popover-body">And here's some amazing content. It's very engaging. Right?</div>
</div>
The button and the popover do not have to be siblings. Anchoring is tied to the invoker, so the
.popover can live anywhere in the document — handy when the button sits inside an
overflow: hidden container.
Four directions
data-bs-placement="top" (the default), bottom, start or
end. The arrow is drawn for the declared side. When the engine flips the popover to the
opposite side for lack of room the arrow stays on its declared side, so prefer placements that usually fit.
HTML
<button type="button" class="btn btn-secondary" popovertarget="popovers-top">Popover on top</button>
<div class="popover fade" popover id="popovers-top" data-bs-placement="top">
<div class="popover-arrow"></div>
<div class="popover-body">Top popover</div>
</div>
<button type="button" class="btn btn-secondary" popovertarget="popovers-end">Popover on end</button>
<div class="popover fade" popover id="popovers-end" data-bs-placement="end">
<div class="popover-arrow"></div>
<div class="popover-body">End popover</div>
</div>
<button type="button" class="btn btn-secondary" popovertarget="popovers-bottom">Popover on bottom</button>
<div class="popover fade" popover id="popovers-bottom" data-bs-placement="bottom">
<div class="popover-arrow"></div>
<div class="popover-body">Bottom popover</div>
</div>
<button type="button" class="btn btn-secondary" popovertarget="popovers-start">Popover on start</button>
<div class="popover fade" popover id="popovers-start" data-bs-placement="start">
<div class="popover-arrow"></div>
<div class="popover-body">Start popover</div>
</div>Custom popovers
Override the --bs-popover-* variables on the element. This one is navy with cream text and a
gold header.
Tale of the tape
HTML
<button type="button" class="btn btn-outline-primary" popovertarget="popovers-custom">Custom popover</button>
<div class="popover fade" popover id="popovers-custom" data-bs-placement="end"
style="--bs-popover-max-width: 220px; --bs-popover-border-color: var(--bs-navy); --bs-popover-bg: var(--bs-navy); --bs-popover-header-bg: var(--bs-gold); --bs-popover-header-color: var(--bs-navy-900); --bs-popover-body-color: var(--bs-cream); --bs-popover-body-padding-x: 1rem; --bs-popover-body-padding-y: 0.5rem;">
<div class="popover-arrow"></div>
<h3 class="popover-header">Tale of the tape</h3>
<div class="popover-body">Height 6'10". Weight 328 lb. From Death Valley.</div>
</div>Stay open
popover="manual" turns off light-dismiss and Escape. The popover stays until a button with
popovertargetaction="hide" or a second press of the toggle closes it. Give it a close button.
Stays put
HTML
<button type="button" class="btn btn-primary" popovertarget="popovers-manual">Dismissible popover</button>
<div class="popover fade" popover="manual" id="popovers-manual" data-bs-placement="end">
<div class="popover-arrow"></div>
<h3 class="popover-header d-flex align-items-center justify-content-between">
Stays put
<button type="button" class="btn-close ms-3" popovertarget="popovers-manual" popovertargetaction="hide" aria-label="Close"></button>
</h3>
<div class="popover-body">Clicking outside does nothing. Close it with the button or the toggle.</div>
</div>Disabled elements
A disabled button cannot invoke anything, so it cannot open a popover. Put the
popovertarget on a neighbouring button, or use a tooltip
on a wrapping span for a hover explanation.
HTML
<button class="btn btn-primary" type="button" disabled>Sign contract</button>
<button class="btn btn-link" type="button" popovertarget="popovers-why" aria-label="Why is this disabled?">Why?</button>
<div class="popover fade" popover id="popovers-why" data-bs-placement="bottom">
<div class="popover-arrow"></div>
<div class="popover-body">Contracts can only be signed after the medical.</div>
</div>Accessibility
- Use a real
<button>as the trigger. Keyboard focus and Enter/Space come free. - The browser moves focus into the popover only if an element inside has
autofocus. For purely informational content leave focus on the button. - Escape closes an auto popover and returns focus to the button. With
popover="manual"include a visible close button. - The
.popover-headeris an<h3>by convention; change the level to fit the page outline, or use a<div>. - Dark mode: colours come from
--bs-body-bgand friends, so the popover followsdata-bs-themeon any ancestor and the system colour scheme.
CSS
All of Bootstrap's --bs-popover-* variables apply:
.popover {
--bs-popover-zindex: 210;
--bs-popover-max-width: 276px;
--bs-popover-font-size: 0.875rem;
--bs-popover-bg: var(--bs-body-bg);
--bs-popover-border-width: var(--bs-border-width);
--bs-popover-border-color: var(--bs-border-color-translucent);
--bs-popover-border-radius: 6px;
--bs-popover-inner-border-radius: calc(6px - var(--bs-border-width));
--bs-popover-box-shadow: var(--bs-box-shadow);
--bs-popover-header-padding-x: 1rem;
--bs-popover-header-padding-y: 0.5rem;
--bs-popover-header-font-size: 1rem;
--bs-popover-header-color: inherit;
--bs-popover-header-bg: var(--bs-secondary-bg);
--bs-popover-body-padding-x: 1rem;
--bs-popover-body-padding-y: 1rem;
--bs-popover-body-color: var(--bs-body-color);
--bs-popover-arrow-width: 1rem;
--bs-popover-arrow-height: 0.5rem;
--bs-popover-arrow-border: var(--bs-popover-border-color);
}
Behavioural selectors:
.popover[popover] // top-layer reset: no UA margin, border or inset
.popover[popover]:popover-open // shown; position-area from data-bs-placement
.popover[data-bs-placement="…"] // arrow geometry (top | bottom | start | end)
.popover.fade:popover-open // opacity 1, from 0 via @starting-style
@supports not (position-area: top) // centered in the viewport, arrow hidden