--- layout: layouts/page.njk title: Popover description: Displays rich content in a portal, triggered by a button. toc: - label: Usage id: usage children: - label: HTML + Javascript id: usage-default - label: Jinja and Nunjucks id: usage-macro --- {% from "macros/code_preview.njk" import code_preview %} {% from "macros/code_block.njk" import code_block %} {% from "popover.njk" import popover %} {% set code_html %} {% call popover( id="demo-popover", trigger="Open popover", trigger_attrs={"class": "btn-outline"}, popover_attrs={"class": "w-80"} ) %}
Set the dimensions for the layer.
The component is structured as such:
<div class="popover"> which wraps around the entire component and holds it state (e.g. open/close).<button> that acts as the trigger to open or close the popover.<div data-popover> that holds the content of the popover.You can set up a few additional options on the <div data-popover> element:
data-side can be set to top, bottom, left, or right to change the side of the popover.data-align can be set to start, center, or end to change the alignment of the popover.You can include the Javascript code provided below, load it as an individual file or use the CLI. Some Alpine.js properties are also required on certain elements (e.g. x-bind, x-data, @click).
You can use the popover() Nunjucks or Jinja macro for this component.
Set the dimensions for the layer.