Skip to content

Popover with Rich Content

Bootstrap 5 popovers with HTML content: profile card with buttons, inline help with links and a delete confirmation, with focus handling.

Also known as: user profile popover, inline help popover, confirmation popover

Popover with Rich Content live demo

Open in new tab

Bootstrap 5 code (HTML, CSS, JS)

A set of Bootstrap 5 popovers with rich HTML content: a profile card with Follow and Message buttons, a help popover with a list and a link, and a delete confirmation with Cancel and Delete actions. Use the pattern for user previews, inline help next to form fields or lightweight confirmations that do not need a full modal.

How it works

The root .rp-demo wraps a small project card and three <template data-rp-template="…"> elements. Each .rp-trigger button names the template it uses in data-rp-template and its position in data-bs-placement; the help and confirm triggers also set a header with data-bs-title.

The script runs on DOMContentLoaded for every .rp-demo and creates each popover with bootstrap.Popover.getOrCreateInstance(), passing html: true, trigger: 'click', container: root and a custom template whose root has role="dialog". The content option returns a fresh clone of the matching <template>, so real DOM nodes (including buttons that Bootstrap's string sanitizer would strip) are inserted on every opening.

On show.bs.popover other open popovers in the same component are hidden. On shown.bs.popover the script sets aria-expanded, links the header with aria-labelledby, moves focus to the first button or link, and wires up the content: data-rp-action="follow" toggles aria-pressed and the label, message, delete and close write to the .rp-status line and close the popover. Escape, a click outside or tabbing out also closes it. The trigger with data-rp-open is opened on load without moving focus, so the preview shows a popover straight away.

Customization

  • --rp-pop-bg, --rp-pop-text and --rp-pop-muted on .rp-demo in style.css: recolour the popover surface, body text and secondary text.
  • --bs-popover-max-width: 300px in .rp-popover: allow wider popovers for longer content.
  • --rp-radius on .rp-demo: changes the corner radius of every popover.
  • data-bs-placement on a .rp-trigger: use top, right, bottom or left; Popper flips it when space runs out.
  • Add a new popover: create a <template data-rp-template="name"> and a button with class="rp-trigger" and data-rp-template="name".
  • Remove data-rp-open from the Maya Patel button so no popover is open on page load.
  • The delete branch in the tip click handler in script.js: replace the status message with a fetch() call to your backend.

Use cases

  • Social and community sites: hovering a name opens a profile card with Follow and Message buttons
  • Forms: a help icon next to a field opens a popover with a short list and a link
  • Admin lists: a delete confirmation with Cancel and Delete avoids a full modal
  • Project cards: popovers show extra details without leaving the page

Accessibility

Popovers use role="dialog" and are labelled by their header or by the trigger text. Triggers carry aria-haspopup="dialog" and an aria-expanded state that follows the popover. Focus moves into the popover when it is opened by the user and returns to the trigger after Escape or an action. The Follow button reports its state with aria-pressed, the icon-only help button has an aria-label, and results are announced through the role="status" paragraph. Focus rings use :focus-visible, and the fade transition is disabled under prefers-reduced-motion.

Usage notes

Requires Bootstrap 5 (added automatically) and Bootstrap Icons. Because templates are found inside each .rp-demo, several instances can share the same template names on one page.

Popover with Rich Content at a glance

Framework
Bootstrap 5
Code
HTML, CSS, JavaScript
JavaScript
Vanilla JavaScript, no jQuery
Dependencies
Bootstrap 5, Bootstrap Icons
Layout
Responsive, works on mobile
Category
Tooltips & Popovers
License
Free for personal and commercial use

Questions about this template

Can I use the Popover with Rich Content code for free?

Yes. You can copy or download the code and use it in personal and commercial projects, including client work. No sign-up is needed. Reselling it as part of a component library or template collection is not allowed; see the license.

How do I add it to my website?

Load Bootstrap 5 and Bootstrap Icons from a CDN (the links are under Requirements). Paste the HTML where the component should appear, add the CSS to your stylesheet and load the JavaScript before the closing </body> tag. Download HTML gives you a complete page with everything already linked.

Does it need jQuery or a JavaScript framework?

No. The script is plain vanilla JavaScript, so it works without jQuery, React or Vue. You can still use the markup inside those frameworks.

Does it work on mobile?

Yes. The layout adapts to small screens. Use the Mobile and Tablet buttons above the live demo to check it at phone and tablet width.

Requirements

Add these to your page (already included in the download):

  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
  • <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
  • <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
Popover with Rich Content – free Bootstrap 5 tooltip & popover template
Popover with Rich Content · free Bootstrap 5 tooltip & popover template

More Tooltips & Popovers

User Hover Card Popover with Photo – free Bootstrap 5 tooltip & popover template

User Hover Card Popover with Photo

Bootstrap 5 popover hover card showing a user photo, cover band, bio, follower stats and a working follow button.

Pure CSS Tooltips – free Pure CSS tooltip & popover template

Pure CSS Tooltips

JavaScript-free tooltips driven by data attributes, with top, right, bottom and left placement, arrows, color tones and hover or focus triggers.