--- 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: JavaScript events id: usage-html-js-4 - 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 data-popover class="popover" id="{ POPOVER_ID }">data-side and data-align attributes.basecoat:initializedbasecoat:initialized event on itself.basecoat:popoverbasecoat:popover event on document. Other popover components (Combobox, Dropdown Menu, Popover and Select) listen for this to close any open popovers.You can use the popover() Nunjucks or Jinja macro for this component.
Set the dimensions for the layer.