Popover
A non-modal panel attached to a trigger, for filters and small forms.
Example
<focsd-popover label="Filter members" closable> <focsd-button slot="trigger">Filters</focsd-button> <focsd-checkbox name="active">Active only</focsd-checkbox> <focsd-button variant="action">Apply</focsd-button></focsd-popover>Usage
Import the module once, then use the tag like any HTML element. Every framework below renders the same element; see Frameworks for setup.
<script type="module"> import '@focsd-dev/components/focsd-popover.js';</script>
<focsd-popover label="Filter members" closable>…</focsd-popover>import { Popover } from '@focsd-dev/react';
export function Example() { return <Popover label="Filter members" closable>…</Popover>;}<script setup>import '@focsd-dev/components/focsd-popover.js';</script>
<template> <focsd-popover label="Filter members" closable>…</focsd-popover></template>// Add CUSTOM_ELEMENTS_SCHEMA to the component's schemas, then:import '@focsd-dev/components/focsd-popover.js';
// template<focsd-popover label="Filter members" closable>…</focsd-popover><script> import '@focsd-dev/components/focsd-popover.js';</script>
<focsd-popover label="Filter members" closable>…</focsd-popover>API
Attributes
| Attribute | Property | Type | Default |
|---|---|---|---|
label | label | string | — |
open | open | boolean | false |
placement | placement | 'top' | 'bottom' | bottom |
closable | closable | boolean | false |
Methods
| Method | Description |
|---|---|
show() | Open the popover and move focus into it. |
hide() | Close the popover. |
Slots
| Slot | Description |
|---|---|
(default) | Default content. |
trigger | The button that opens the popover. |
CSS parts
Style the inside of the component with ::part(), for example focsd-popover::part(close).
| Part | Description |
|---|---|
close | The close (×) button, with `closable`; focus returns to the trigger. |
panel | The panel element. |
Accessibility
- The panel is a non-modal
role="dialog"named bylabel; the trigger getsaria-expandedandaria-haspopup="dialog". - Focus moves to the first focusable element in the panel and returns to the trigger on Escape or outside click.
closableadds a close (×) button named "Close" to the panel, useful on touch screens and for panels with a form. It returns focus to the trigger.- Positioned with CSS anchor positioning in the top layer (
popoverAPI).
Keyboard
| Key | Action |
|---|---|
| Enter / Space (trigger) | Open or close |
| Escape | Close and return focus to the trigger |
Ask the docs
Hi, what are you building?
Ask about any component, theming, forms or frameworks. I answer with the right component, a snippet and a link to its docs.