Skip to content
Nana UI

Layout & Containers

Popover

A panel anchored to a trigger, opened and closed by the app.

View .md Download

Popover is a Svelte component. In the web components an anchored panel is nana-popup.

npx @nana-tec/ui add popover --framework svelte

Lands in src/lib/components/ui/popover/ as NanaPopover.svelte, styled with Tailwind classes that resolve to the design tokens. Requires Tailwind v4.

<script lang="ts">
import { NanaPopover } from '$lib/components/ui/popover';
let open = $state(false);
</script>
<NanaPopover bind:open title="Filters" placement="bottom-start">
{#snippet trigger({ props })}
<button {...props}>Filters</button>
{/snippet}
...
</NanaPopover>

Spread props onto the element that opens it. Focus moves into the popover when it opens; Escape closes it and returns focus to the trigger, and a press outside closes it. children receives close for buttons inside.

NanaPopover

PropTypeDefault
openbind:booleanfalse
placementPlacement'bottom-start'
gapnumber8
labelstring
titlestring
unstyledbooleanfalse
initialFocus'first' | 'content' | 'none''first'
onOpenChange(open: boolean) => void
triggerrequiredSnippet<[{ props: PopoverTriggerProps }]>
childrenSnippet<[{ close: () => void }]>

Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'title' | 'children'>.