Skip to content

kit-popover

kit-popover is itself a native popover target. Register its optional class explicitly; /register continues to register the eleven default components.

import { KitPopoverElement } from '@atheory-ai/kitsune-ui/elements/kit-popover'
customElements.define('kit-popover', KitPopoverElement)
<button popovertarget="asset-help">Asset help</button>
<kit-popover id="asset-help" aria-label="Asset help" placement="below">
<p>Working drafts are separate from saved asset values.</p>
<button popovertarget="asset-help" popovertargetaction="hide">Close</button>
</kit-popover>

Use ordinary native popover="auto" (the default), popover="manual", popovertargetaction and inherited showPopover(), hidePopover() and togglePopover(). Invokers and targets must share the native ID-reference scope. A programmatic call can supply showPopover({ source: button }) to establish an implicit anchor. Without a source, choose placement="center" for predictable unanchored positioning.

The browser owns top-layer rendering, auto-mode light dismissal, Escape and focus behavior. Popovers are non-modal. Menu, listbox, tooltip and dialog accessibility semantics are distinct patterns; this component supplies none of their keyboard models or roles automatically. Give content an appropriate accessible name and ordinary labeled controls. Use kit-dialog for modal interaction.

placement accepts below, above, inline-start, inline-end and center. Native CSS anchor positioning follows the actual invoker, uses logical directions and tries opposite placements to fit the viewport. There are no document-global anchor names, geometry polling or JavaScript positioning engine. Without supported anchor placement, the browser’s centered popover positioning remains. Without Popover API support, the content remains inline; no emulated top layer is installed.

The read-only open getter observes actual native state. The composed, bubbling kit-popover-toggle event has { open: boolean } detail and forwards the browser’s coalesced toggle facts. It may follow a programmatic open and is not evidence of a user gesture, successful command or authority. Do not bind an authoritative writer to open; native methods and the invoker own this transient UI. Standard beforetoggle and toggle events remain available directly on the element.

Slots accept trusted DOM content; no HTML string interpreter is provided. Theme variables inherit normally. Surface, text, border, radius, focus and padding use existing --kit-* variables; --kit-popover-gap controls anchor spacing. Compatible native movement preserves the same input, focus and open state; ordinary removal lets the browser close it. There are no document listeners, observers or timers to dispose. Imports register nothing and create no runtime.