Ant Design Svelte

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

Title and content

Information card is opened by hovering or focusing.

Three ways to open

Pointing with focus, only focus and click.

12 positions

Twelve positions

Basic and angular directions relative to the button.

Arrow

Normal arrow, disable and pointAtCenter.

Automatic offset

Turn on experience at the bottom edge of the viewport and open the action card.

Open: no

Closing from content

The button inside the card changes bind:open and returns focus to trigger.

Pointing with pressing

Two embedded cards: explanation for hover/focus and details for click.

Semantic DOM

The object and function style the container, title, content, and arrow.

General settings

ConfigProvider.popover and local priority trigger/arrow.

Component tokens

Local titleMinWidth and zIndexPopup.

Open: no

Draft and delete content

The local state of the child component is preserved until destroyOnHidden.

Popup container

getPopupContainer selects the DOM node for the surface.

Ref and forceAlign

Change layout, tick and forced position update.

In the card: Анна

Profile editor from review

Save and cancel draft, card position and focus.

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.

Topics of official examples
ThemeExample
BasicHeading and content Snippet.
Three ways to triggerHover, focus and click.
Placement12 physical directions.
Arrowtrue, false and pointAtCenter.
Auto ShiftReal edge viewport and interactive content.
Controlling the close of the dialogbind:open and action in content.
Hover with click popoverNested managed cards; click hides the hover card.
Custom semantic dom stylingCSS string object and function.
Main parameters
PropertyDescriptionTypeDefault
uniqueUses the shared surface of the nearest Tooltip.UniqueProvider.booleanfalse
motionCSS transition name. An empty string disables animation.{ motionName?: string }zoom-big
afterOpenChangeRuns after a standalone popup finishes its transition.(open: boolean) => void—
prefixClsFull local CSS prefix of popup Popover and standard openClassName. The empty string and undefined inherit ConfigProvider.prefixCls; the default is ant-popover.stringConfigProvider + -popover
titleTitle: string, number or Snippet; false omits the section, true leaves it empty.PopoverContent | null—
contentCard contents, including fields and actions.PopoverContent | null—
openSupports bind:open.boolean | undefinedlocal state
defaultOpenInitial local state.booleanfalse
onOpenChangeChange the visibility of the card.(open: boolean) => void—
triggerhover, 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
placementFour main and eight angular directions.PopoverPlacementtop
alignPointAnchors the popup to the pointer coordinates.booleanfalse
arrowVisibility and arrow direction to the center.TooltipArrowtrue
autoAdjustOverflowCorrection at the edge of the visible area.boolean | AdjustOverflowtrue
getPopupContainerBrowser-only selection of DOM container.(trigger: HTMLElement) => HTMLElementnative inline / context
freshUpdates hidden scalar payload; Snippet retains its own reactivity.booleanfalse
destroyOnHiddenRemoves title/content when closing; native shell is preserved.booleanfalse
forceRenderPre-mounts hidden content and portal after hydration.booleanfalse
mouseEnterDelayHover opening delay in seconds.number0.1
mouseLeaveDelayHover-closing delay in seconds.number0.1
stylesCSS lines by semantic slots; object or function with props.PopoverSemantic—
classNamesClasses by semantic slots; object or function.PopoverSemantic—
zIndexExplicit CSS layer before semantic root styles.numbertheme

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.

SlotPurpose
rootpopup surface and position.
containerBackground, padding, radius and shadow.
arrowCard arrow.
titleHeading.
contentMain 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.

Core Component Tokens
TokenPurpose
titleMinWidthMinimum header width.
zIndexPopupCSS layer of the card.
Common tokens of the current topic
TokenMeaning
colorBgElevated#ffffff
colorTextrgba(0,0,0,0.88)
colorTextHeadingrgba(0,0,0,0.88)
fontSize14
fontWeightStrong600
lineHeight1.5714285714285714
borderRadiusLG8
sizePopupArrow16

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.