Popover
Pop-up cards with actions, shapes, focus and controlled state.
When to use
Popover shows additional information and actions next to the element. Unlike a Tooltip, its content can include buttons and fields. Popconfirm is suitable for a short confirmation of the operation; for a mandatory multi-step action - Modal.
Opening and contents of the card
children - trigger-snippet, title and content - values or content snippets. Use an available button or link as a trigger. trigger selects hover, focus, click, contextMenu or a combination of them; for touch, provide pressing.
| Problem | Setting | Example |
|---|---|---|
| Show explanation | title, content |
Main card |
| Select opening events | trigger |
Opening methods |
| Close with internal button | bind:open |
External condition |
| Save draft | destroyOnHidden |
Life cycle |
| Remeasure position | bind:ref, forceAlign |
Recalculation |
defaultOpen specifies the initial local state. bind:open synchronizes opening with the application; onOpenChange reports the change request. With click-trigger, pressing again and clicking outside closes the card, Escape closes the current surface. A button inside content can set open=false.
Save content and focus
By default, visited content is saved after closing. destroyOnHidden removes it and the child component's local state. forceRender creates hidden content after hydration. For a draft that needs to survive DOM removal, keep the data with the owner of the Popover.
fresh updates hidden scalar title/content and associated semantic styles. Svelte snippet continues to read the captured reactive state; There is no complete React.memo freezing of its values. Don't use fresh as a draft storage mechanism.
After saving or canceling, return focus to the original action. For complex shapes, consider Tab transitions and closing methods. Hover without keyboard and touch access is not suitable as the only path to interactive content.
Position and design
placement supports twelve main and corner positions. With autoAdjustOverflow, the main directions allow flip and shift; angular ones keep the snap to the trigger edge and use flip. arrow can be disabled or set to pointAtCenter.
GetPopupContainer selects a DOM container. After changing the geometry, wait for the tick and call ref.forceAlign(); The method is available after mount and does not open a closed card. An open trigger is also tracked automatically.
ConfigProvider.popover sets its own defaults; Tooltip settings are not applied to it. Semantic slots include root/container/arrow/title/content, styles are specified by CSS strings. Popover design tokens, including titleMinWidth and zIndexPopup, are applied through the local theme. color changes the surface and arrow; Separate semantic header and content colors are preserved.
To share a popup with nearby tooltips, place the popover in Tooltip.UniqueProvider and enable unique. The popover keeps its dialog role. Shared popup example.
A non-empty local prefixCls specifies the popup classes and the standard openClassName. The empty string and undefined inherit ConfigProvider.prefixCls with the -popover suffix, defaulting to ant-popover. Programmatic change of prefix preserves the open popup and DOM of the editor; simply clicking outside the panel still closes it. Example ConfigProvider shows these settings along with Slider.
Examples
Documentation and example components are in one section.
For additional actions, the card can contain buttons and links.
Title and content
Information card is opened by hovering or focusing.
<script lang="ts">
import { Button, Popover } from '@woodger/antd';
</script>
<style>
p { margin: 0 0 8px; }
p:last-child { margin-bottom: 0; }
</style>
{#snippet content()}
<p>{("Documentation and example components are in one section.")}</p>
<p>{("For additional actions, the card can contain buttons and links.")}</p>
{/snippet}
<Popover title={("About the project")} content={(content)} trigger={[
'hover',
'focus'
]}>
<Button type="primary">{("Project information")}</Button>
</Popover>
Three ways to open
Pointing with focus, only focus and click.
<script lang="ts">
import { Button, Popover } from '@woodger/antd';
</script>
<style>
.examples {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
</style>
<div class="examples">
<Popover title={("Guidance card")} content={("Point and focus is triggered.")}
trigger={['hover', 'focus']}><Button>{("Guidance")}</Button></Popover>
<Popover title={("Card by focus")} content={("Opens when switching from the keyboard.")}
trigger="focus"><Button>{("Focus")}</Button></Popover>
<Popover title={("Card by click")} content={("Pressing again closes the card.")}
trigger="click"><Button>{("Press")}</Button></Popover>
</div>
Twelve positions
Basic and angular directions relative to the button.
<script lang="ts">
import { Button, Popover, type PopoverPlacement } from '@woodger/antd';
const positions = [
{ value: 'topLeft', label: 'TL', row: 1, column: 1 },
{ value: 'top', label: 'Top', row: 1, column: 2 },
{ value: 'topRight', label: 'TR', row: 1, column: 3 },
{ value: 'leftTop', label: 'LT', row: 2, column: 1 },
{ value: 'left', label: 'Left', row: 3, column: 1 },
{ value: 'leftBottom', label: 'LB', row: 4, column: 1 },
{ value: 'rightTop', label: 'RT', row: 2, column: 3 },
{ value: 'right', label: 'Right', row: 3, column: 3 },
{ value: 'rightBottom', label: 'RB', row: 4, column: 3 },
{ value: 'bottomLeft', label: 'BL', row: 5, column: 1 },
{ value: 'bottom', label: 'Bottom', row: 5, column: 2 },
{ value: 'bottomRight', label: 'BR', row: 5, column: 3 }
] as const satisfies readonly {
value: PopoverPlacement; label: string; row: number; column: number;
}[];
</script>
<style>
.positions {
display: grid;
grid-template-columns: repeat(3, minmax(0, 1fr));
gap: 8px;
}
.cell {
display: flex;
justify-content: center;
}
.center {
grid-row: 2 / 5;
grid-column: 2;
display: grid;
place-items: center;
text-align: center;
color: var(--ant-color-text-secondary);
}
</style>
<div class="positions">
{#each positions as position (position.value)}
<div
class="cell"
style:grid-row={(position.row)}
style:grid-column={(position.column)}
>
<Popover title={("Position: " + String((position.value)) + "")} content={("Card contents")}
placement={position.value} trigger="click">
<Button aria-label={("Position " + String((position.value)) + "")}>{(position.label)}</Button>
</Popover>
</div>
{/each}
<div class="center">{("12 positions")}</div>
</div>
Arrow
Normal arrow, disable and pointAtCenter.
<script lang="ts">
import { Button, Popover } from '@woodger/antd';
</script>
<style>
.examples {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
</style>
<div class="examples">
<Popover
title={("Standard pointer")}
content={("The arrow follows the position of the popup.")}
placement="topLeft"
trigger="click"
><Button>{("Regular hand")}</Button></Popover>
<Popover title={("Without arrow")} content={("arrow=false hides the arrow.")} arrow={false}
trigger="click"><Button>{("Without arrow")}</Button></Popover>
<Popover title={("Arrow in the center")} content={("The pointer is directed to the center of the button.")}
arrow={{ pointAtCenter: true }} placement="topLeft" trigger="click">
<Button>{("Center button")}</Button>
</Popover>
</div>
Automatic offset
Turn on experience at the bottom edge of the viewport and open the action card.
<script lang="ts">
import { Button, Checkbox, Popover } from '@woodger/antd';
let enabled = $state(false);
let open = $state(false);
</script>
<style>
.edge {
position: fixed;
right: 12px;
bottom: 12px;
z-index: 20;
display: flex;
align-items: center;
gap: 8px;
}
</style>
{#snippet content()}
<p>{("At the bottom edge the card changes position and remains inside the window.")}</p>
<Button onclick={() => { open = false; }}>{("Close the card at the edge")}</Button>
{/snippet}
<Checkbox bind:checked={enabled}>{("Show card at the edge of the screen")}</Checkbox>
{#if enabled}
<div class="edge">
<Popover
title={("Card at the edge")}
content={(content)}
placement="bottom"
trigger="click"
bind:open
>
<Button type="primary">{("At the edge of the window")}</Button>
</Popover>
<Button
aria-label={("Remove the button at the edge")}
onclick={() => { enabled = false; }}
>×</Button>
</div>
{/if}
Content can close the card through the owner's state.
Open: no
Closing from content
The button inside the card changes bind:open and returns focus to trigger.
<script lang="ts">
import { Button, Popover } from '@woodger/antd';
let open = $state(false);
</script>
{#snippet content()}
<p>{("Content can close the card through the owner's state.")}</p>
<Button onclick={() => { open = false; }}>{("Close managed card")}</Button>
{/snippet}
<Popover
title={("Managed card")}
content={(content)}
trigger="click"
bind:open
>
<Button>{("Open managed card")}</Button>
</Popover>
<p
role="status"
aria-label={("Visibility Popover")}
>{("Open: ")}{(open ? "yes" : "no")}</p>
Clicking opened a separate interactive card.
Pointing with pressing
Two embedded cards: explanation for hover/focus and details for click.
<script lang="ts">
import { Button, Popover } from '@woodger/antd';
let hovered = $state(false);
let clicked = $state(false);
</script>
{#snippet details()}
<p>{("Clicking opened a separate interactive card.")}</p>
<Button onclick={() => { clicked = false; }}>{("Close details")}</Button>
{/snippet}
<Popover title={("Explanation when hovering")} content={("Click the button to open details.")}
trigger={['hover', 'focus']} disabled={clicked} bind:open={hovered}>
<Popover
title={("Click for details")}
content={(details)}
trigger="click"
bind:open={clicked}
onOpenChange={next => { if (next) hovered = false; }}
>
<Button>{("Point and click")}</Button>
</Popover>
</Popover>
Semantic DOM
The object and function style the container, title, content, and arrow.
<script lang="ts">
import { Button, Popover } from '@woodger/antd';
</script>
<style>
.examples {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
</style>
<div class="examples">
<Popover title={("Styles by object")} content={("Custom header and content styles.")}
trigger="click" classNames={{ root: 'popover-semantic-object' }}
styles={{
container: 'border-radius:12px',
title: `
color: var(--ant-color-primary-text);
font-weight: 600;
`,
content: 'padding-top:8px',
arrow: 'opacity:0.65'
}}>
<Button>{("styles object")}</Button>
</Popover>
<Popover title={("Styles function")} content={("The function receives card props.")}
trigger="click" placement="top" classNames={() => ({ root: 'popover-semantic-function' })}
styles={({ props }) => ({
title: props.placement === 'top'
? 'font-weight:700'
: 'font-weight:400'
})}>
<Button>{("Function styles")}</Button>
</Popover>
</div>
General settings
ConfigProvider.popover and local priority trigger/arrow.
<script lang="ts">
import { Button, ConfigProvider, Popover } from '@woodger/antd';
</script>
<style>
.examples {
display: flex;
flex-wrap: wrap;
gap: 12px;
}
</style>
<ConfigProvider popover={{ trigger: 'click', arrow: false, mouseEnterDelay: 0 }}>
<div class="examples">
<Popover title={("Context settings")} content={("Open by click, without arrow.")}>
<Button>{("General settings")}</Button>
</Popover>
<Popover title={("Local settings")} content={("Focus and arrow are enabled locally.")}
trigger="focus" arrow><Button>{("Local focus")}</Button></Popover>
</div>
</ConfigProvider>
Component tokens
Local titleMinWidth and zIndexPopup.
<script lang="ts">
import { Button, ConfigProvider, Popover } from '@woodger/antd';
</script>
<ConfigProvider theme={{ components: { Popover: { titleMinWidth: 160, zIndexPopup: 1130 } } }}>
<Popover title={("Local topic")} content={("Custom header width and CSS layer.")}
trigger="click"><Button>{("Popover Tokens")}</Button></Popover>
</ConfigProvider>
Open: no
Draft and delete content
The local state of the child component is preserved until destroyOnHidden.
DraftEditor.svelte<script lang="ts"> import { Input } from '@woodger/antd'; const id = $props.id(); let draft = $state<string | undefined>(("Draft")); </script> <style> .field { width: 220px; max-width: 100%; } label { display: block; margin-bottom: 8px; } </style> <div class="field"> <label for={id}>{("Local draft Popover")}</label> <Input {id} bind:value={draft} /> </div>Lifecycle.svelte<script lang="ts"> import { Button, Checkbox, Popover } from '@woodger/antd'; import DraftEditor from './DraftEditor.svelte'; let open = $state(false); let destroy = $state(false); </script> <style> .controls { margin-bottom: 20px; } </style> {#snippet content()}<DraftEditor />{/snippet} <div class="controls"> <Checkbox bind:checked={destroy}> {("Delete draft when closing")} </Checkbox> </div> <Popover title={("Card life cycle")} content={(content)} destroyOnHidden={destroy} trigger="click" bind:open > <Button>{("Open draft")}</Button> </Popover> <p role="status" aria-label={("Popover editor visibility")}>{("Open: ")}{(open ? "yes" : "no")}</p>
Popup container
getPopupContainer selects the DOM node for the surface.
<script lang="ts">
import { Button, Popover } from '@woodger/antd';
let container = $state<HTMLDivElement>();
</script>
<style>
.container {
padding: 20px;
border: 1px dashed var(--ant-color-border);
border-radius: 8px;
}
</style>
<div class="container" bind:this={container}>
<Popover title={("Own container")} content={("Popup is transferred to the selected DOM node.")}
getPopupContainer={trigger => container ?? trigger.ownerDocument.body} trigger="click">
<Button>{("Open in container")}</Button>
</Popover>
</div>
Ref and forceAlign
Change layout, tick and forced position update.
<script lang="ts">
import { tick } from 'svelte';
import { Button, Popover, type PopoverRef } from '@woodger/antd';
let ref = $state<PopoverRef>();
let open = $state(false);
let expanded = $state(false);
async function changeLayout() {
expanded = !expanded;
await tick();
ref?.forceAlign();
}
</script>
<style>
.extra {
margin-top: 16px;
padding: 24px 12px;
background: var(--ant-color-fill-quaternary);
}
.trigger { margin-top: 24px; }
</style>
<Button onclick={changeLayout}>{("Change location")}</Button>
{#if expanded}<div class="extra">{("Block before trigger.")}</div>{/if}
<div class="trigger">
<Popover title={("Movable card")} content={("forceAlign is called after tick.")}
trigger={[]} hideAction={[]} placement="right" bind:open bind:ref>
<Button onclick={() => { open = !open; }}>{("Binding to a button")}</Button>
</Popover>
</div>
The name appears on the participant card. You can change it in the editor nearby.
Profile editor from review
Save and cancel draft, card position and focus.
<script lang="ts">
import { Button, Checkbox, Input, Popover, type PopoverPlacement } from '@woodger/antd';
const generatedId = $props.id();
let open = $state(false);
let detailsOpen = $state(false);
let placement = $state<PopoverPlacement>('top');
let arrow = $state(true);
const initialName = "Anna";
let name = $state(initialName);
let draft = $state(initialName);
function save(event: SubmitEvent) {
event.preventDefault();
name = draft.trim();
open = false;
}
</script>
<style>
.settings, .examples, .actions {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
}
.settings { margin-bottom: 28px; }
.settings label {
display: flex;
align-items: center;
gap: 8px;
}
select {
padding: 4px 8px;
color: var(--ant-color-text);
background: var(--ant-color-bg-container);
border: 1px solid var(--ant-color-border);
border-radius: 6px;
font: inherit;
}
.editor {
width: 260px;
max-width: 100%;
}
.editor label {
display: block;
margin-bottom: 8px;
}
.actions { margin-top: 16px; }
.details { max-width: 260px; }
.details p { margin: 0 0 16px; }
output {
display: block;
margin-top: 20px;
color: var(--ant-color-text-secondary);
}
</style>
{#snippet editor()}
<form class="editor" onsubmit={save}>
<label for={`${generatedId}-name`}>{("Profile name")}</label>
<Input id={`${generatedId}-name`} bind:value={draft} required pattern=".*\S.*" />
<div class="actions"><Button htmlType="submit" type="primary">
{("Save profile")}
</Button><Button
onclick={() => { open = false; }}
>{("Cancel")}</Button></div>
</form>
{/snippet}
{#snippet details()}
<div class="details"><p>{("The name appears on the participant card. You can change it in the editor nearby.")}</p><Button
onclick={() => { detailsOpen = false; }}
>{("I see")}</Button></div>
{/snippet}
<div class="settings">
<label>{("Card position ")}<select
bind:value={placement}
><option
value="top"
>{("Top")}</option><option
value="bottom"
>{("Bottom")}</option><option
value="left"
>{("Left")}</option><option
value="right"
>{("Right")}</option></select></label>
<Checkbox bind:checked={arrow}>{("Card arrow")}</Checkbox>
</div>
<div class="examples">
<Popover
title={("Editing profile")}
content={(editor)}
trigger="click"
bind:open
{placement}
{arrow}
onOpenChange={(next) => { if (next) draft = name; }}
><Button>{("Set up profile")}</Button></Popover>
<Popover
title={("Member profile")}
content={(details)}
bind:open={detailsOpen}
{placement}
{arrow}
><Button>{("Profile details")}</Button></Popover>
</div>
<output
aria-label={("Saved profile name")}
>{("In the card: ")}{name}</output>
API
Verified against eight ant.design 6.7.0 themes and public Svelte API based on 6.6.8. ReactNode is replaced with values and snippets, CSSProperties with CSS strings. Full definitions of Props are in the package.
| Theme | Example |
|---|---|
| Basic | Heading and content Snippet. |
| Three ways to trigger | Hover, focus and click. |
| Placement | 12 physical directions. |
| Arrow | true, false and pointAtCenter. |
| Auto Shift | Real edge viewport and interactive content. |
| Controlling the close of the dialog | bind:open and action in content. |
| Hover with click popover | Nested managed cards; click hides the hover card. |
| Custom semantic dom styling | CSS string object and function. |
| Property | Description | Type | Default |
|---|---|---|---|
unique | Uses the shared surface of the nearest Tooltip.UniqueProvider. | boolean | false |
motion | CSS transition name. An empty string disables animation. | { motionName?: string } | zoom-big |
afterOpenChange | Runs after a standalone popup finishes its transition. | (open: boolean) => void | — |
prefixCls | Full local CSS prefix of popup Popover and standard openClassName. The empty string and undefined inherit ConfigProvider.prefixCls; the default is ant-popover. | string | ConfigProvider + -popover |
title | Title: string, number or Snippet; false omits the section, true leaves it empty. | PopoverContent | null | — |
content | Card contents, including fields and actions. | PopoverContent | null | — |
open | Supports bind:open. | boolean | undefined | local state |
defaultOpen | Initial local state. | boolean | false |
onOpenChange | Change the visibility of the card. | (open: boolean) => void | — |
trigger | hover, focus, click, contextMenu; For the keyboard, explicitly enable focus. | PopoverTrigger | readonly PopoverTrigger[] | native hover/focus/context |
hideAction | [] disables trigger/outside closure, preserving Escape and content actions. | readonly PopoverTrigger[] | trigger |
placement | Four main and eight angular directions. | PopoverPlacement | top |
alignPoint | Anchors the popup to the pointer coordinates. | boolean | false |
arrow | Visibility and arrow direction to the center. | TooltipArrow | true |
autoAdjustOverflow | Correction at the edge of the visible area. | boolean | AdjustOverflow | true |
getPopupContainer | Browser-only selection of DOM container. | (trigger: HTMLElement) => HTMLElement | native inline / context |
fresh | Updates hidden scalar payload; Snippet retains its own reactivity. | boolean | false |
destroyOnHidden | Removes title/content when closing; native shell is preserved. | boolean | false |
forceRender | Pre-mounts hidden content and portal after hydration. | boolean | false |
mouseEnterDelay | Hover opening delay in seconds. | number | 0.1 |
mouseLeaveDelay | Hover-closing delay in seconds. | number | 0.1 |
styles | CSS lines by semantic slots; object or function with props. | PopoverSemantic | — |
classNames | Classes by semantic slots; object or function. | PopoverSemantic | — |
zIndex | Explicit CSS layer before semantic root styles. | number | theme |
ConfigProvider and ref
popover sets its own trigger, arrow, delays and semantic styles; the ConfigProvider.tooltip settings do not apply to it. Local props clarify the context. The nested provider replaces the entire popover object; undefined inherits from the parent.
bind:ref provides PopoverRef: nativeElement, popupElement and forceAlign. Handle is available after mount and is cleared upon unmount. Native div shell persists after closing; forceAlign updates the position without revealing the hidden card.
Semantic DOM
The surface has role=dialog and an accessible name by title or aria-label. Native fields and buttons in content are accessible from the keyboard. In the editor, the first input gets focus when opened, closing from the content returns it to trigger.
| Slot | Purpose |
|---|---|
root | popup surface and position. |
container | Background, padding, radius and shadow. |
arrow | Card arrow. |
title | Heading. |
content | Main content. |
classNames and styles accept an object or function with props. By default, the native popover remains next to the trigger in the DOM and opens in the top layer. getPopupContainer selects another DOM container; its getter is only called in the browser.
Registration tokens
A nested popover uses the dialog layer as its base. Set zIndex for an explicit layer.
| Token | Purpose |
|---|---|
titleMinWidth | Minimum header width. |
zIndexPopup | CSS layer of the card. |
| Token | Meaning |
|---|---|
colorBgElevated | #ffffff |
colorText | rgba(0,0,0,0.88) |
colorTextHeading | rgba(0,0,0,0.88) |
fontSize | 14 |
fontWeightStrong | 600 |
lineHeight | 1.5714285714285714 |
borderRadiusLG | 8 |
sizePopupArrow | 16 |
FAQ
How to close Popover from content?
Use bind:open and set false in the button handler. Keep focus clear returning to trigger.
How not to lose a draft?
Without destroyOnHidden, the visited content is saved. To be independent of DOM removal, raise the state to the owner.
What does fresh change?
Update hidden scalar title/content and semantic styles. It does not freeze the reactive state inside the Svelte snippet.
Why did the card move at the edge of the window?
autoAdjustOverflow adjusts placement. The main directions allow flip/shift, the corner directions allow flip while maintaining the snap to the edge.