Layout & Containers
Popover
A panel anchored to a trigger, opened and closed by the app.
Popover is a Svelte component. In the web components an anchored panel is
nana-popup.
<script lang="ts">
import { NanaPopover } from '$lib/components/ui/popover';
import { NanaButton } from '$lib/components/ui/button';
import { NanaInput } from '$lib/components/ui/input';
</script>
<NanaPopover title="Rename unit">
{#snippet trigger({ props })}
<NanaButton variant="outline" {...props}>Rename</NanaButton>
{/snippet}
{#snippet children({ close })}
<div class="flex w-64 flex-col gap-3">
<NanaInput label="Name" value="Unit 4B" />
<div class="flex justify-end gap-2">
<NanaButton variant="ghost" size="sm" onclick={close}>Cancel</NanaButton>
<NanaButton size="sm" onclick={close}>Save</NanaButton>
</div>
</div>
{/snippet}
</NanaPopover> Installation
Section titled “Installation”npx @nana-tec/ui add popover --framework svelteLands 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
| Prop | Type | Default |
|---|---|---|
openbind: | boolean | false |
placement | Placement | 'bottom-start' |
gap | number | 8 |
label | string | |
title | string | |
unstyled | boolean | false |
initialFocus | 'first' | 'content' | 'none' | 'first' |
onOpenChange | (open: boolean) => void | |
triggerrequired | Snippet<[{ props: PopoverTriggerProps }]> | |
children | Snippet<[{ close: () => void }]> |
Also accepts Omit<HTMLAttributes<HTMLDivElement>, 'class' | 'title' | 'children'>.