--- 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-html-js children: - label: "Step 1 (Optional): Include the JavaScript file" id: usage-html-js-1 - label: "Step 2: Add your popover HTML" id: usage-html-js-2 - label: HTML structure id: usage-html-js-3 - 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.
You can either include the JavaScript file for all the components, or just the one for this component by adding this to the <head> of your page:
<button type="button" popovertarget="{ POPOVER_ID }">The trigger to open the popover, can also have the following attributes:
id="{BUTTON_ID}": linked to by the aria-labelledby attribute of the listbox.aria-expanded="false": tracks the popover's state.onclick: a simple function to update aria-expanded.<div popover class="popover" id="{ POPOVER_ID }">data-side and data-align attributes.You can use the popover() Nunjucks or Jinja macro for this component.
Set the dimensions for the layer.