--- title: Popover summary: A popover is a small overlay with a title and a body, for information that doesn't fit in a tooltip. description: Show extra information in popovers when a tooltip is not enough. Set the placement and trigger to control how they appear. related: [/ui/components/tooltip, /ui/components/dropdown] source: core/scss/ui/_popovers.scss css-vars: popover classnames: component: - class: popover desc: Container element, positioned by Bootstrap part: - class: popover-header desc: Title bar - class: popover-body desc: Content area - class: popover-arrow desc: Pointer towards the trigger, positioned by Bootstrap --- import Example from '@components/Example.astro'; import CodeDocs from '@components/CodeDocs.astro'; ## Default markup To create a default popover use: ## Four directions Four options are available: `top`, `right`, `bottom`, and `left` aligned. Directions are mirrored when using Bootstrap in [RTL](/ui/getting-started/rtl).
## Popover on hover A popover can open on `click`, `hover`, `focus` or `manual`, set with `data-bs-trigger`. This one opens on hover. See the [Bootstrap documentation](https://getbootstrap.com/docs) for the details. ## JavaScript Tabler automatically initializes all elements with `data-bs-toggle="popover"` on page load. This is the code that runs: To use your own options, create the instance yourself. It replaces the one Tabler created, so only your options apply: ```js const el = document.getElementById('my-popover'); new tabler.Popover(el, { customClass: 'popover-wide', trigger: 'focus' }); ``` To read or control the existing instance without changing its options, use `tabler.Popover.getInstance(el)` or `tabler.Popover.getOrCreateInstance(el)`. ## Accessibility - The trigger must be a `button` or a link with an `href`, so it can take focus. Bootstrap manages `aria-describedby` while the popover is open. - Popovers open on click by default, which is what makes their content reachable. If you switch to `data-bs-trigger="hover"`, the content becomes unreachable by keyboard. - Set `data-bs-trigger="focus"` to make a popover dismiss itself when focus leaves, which is the closest thing to Escape behavior. - Tabler enables HTML in a popover only when you set `data-bs-html="true"`. Leave it off for content that comes from users. - Keep the title and body as text. A popover holding a form is a modal in disguise - use a real dialog for that.