Skip to main content

An accessible popup anchored to a button.

Features

Installation

typo3 ui:add popover

Read more about installing Components and Primitives.

Examples

With Close Button

Show a close button inside the popover.

Custom Positioning

Control where the popover appears relative to the trigger.

Modal Mode

Make the popover modal to trap focus and block interaction with the rest of the page.

Localization

Default close trigger labels are shipped via XLF and follow the current Site Language. For per-template overrides, pass translated strings through the translations prop. Set closeTriggerLabel to {false} or an empty string to omit the aria-label.

<ui:popover.root
    translations="{
        closeTriggerLabel: f:translate(key: 'LLL:EXT:site_package/Resources/Private/Language/locallang.xlf:popover.close')
    }"
>
    ...
</ui:popover.root>

API Reference

The following tables cover the available props of the Fluid Primitives. For a full list of available client side props and methods, see the Zag.js Machine API.

popover.root

Provides popover state and context for the composed parts. Renders no wrapper element.

NameDescriptionRequiredDefault
modalboolean
Whether the popover should be modal.
No
false
portalledboolean
Whether the popover is portalled and proxies tabbing behavior regardless of DOM position.
No
true
autoFocusboolean
Whether to automatically set focus on the first focusable content within the popover when opened.
No
true
restoreFocusboolean
Whether to restore focus to the element that had focus before the popover was opened.
No
true
closeOnInteractOutsideboolean
Whether to close the popover when the user clicks outside of the popover.
No
true
closeOnEscapeboolean
Whether to close the popover when the escape key is pressed.
No
true
positioningarray
The user provided options used to position the popover content.
No
-
defaultOpenboolean
The initial open state of the popover when rendered. Use when you don't need to control the open state of the popover.
No
false
translationsarray
Localized popover labels. Set entries to `` to omit the corresponding `aria-label`. Use `f:translate` for per-template localization overrides when needed.
No
-
rootIdstring
The root ID of the component, used for hydration and identification.
No
-
idsarray
The IDs of of the component parts for composition.
No
[]
controlledboolean
If true, the component is meant to be initialized manually inside another component
No
false

popover.trigger

Opens and closes the popover. Renders a <button> element.

NameDescriptionRequiredDefault
valuestring
No
-
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Rendered data attributes

AttributeDescription
data-scopepopover
data-parttrigger
data-placementThe placement of the trigger
data-sideThe side of the trigger that the trigger is positioned on
data-valueThe value of the item
data-currentPresent when current
data-state"open" | "closed"

popover.positioner

Positions the popover content relative to the trigger. Renders a <div> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

popover.content

Contains the popover panel content. Renders a <div> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Rendered data attributes

AttributeDescription
data-scopepopover
data-partcontent
data-state"open" | "closed"
data-nestedpopover
data-has-nestedpopover
data-expandedPresent when expanded
data-placementThe placement of the content
data-sideThe side of the trigger that the content is positioned on

popover.arrow

Displays a decorative arrow for the popover. Renders a <div> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

popover.indicator

Displays a decorative state indicator. Renders a <div> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Rendered data attributes

AttributeDescription
data-scopepopover
data-partindicator
data-state"open" | "closed"

popover.title

Provides the accessible title for the popover. Renders a <div> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

popover.description

Provides supporting descriptive text for the popover. Renders a <div> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

popover.closeTrigger

Closes the popover when activated. Renders a <button> element.

NameDescriptionRequiredDefault
asChildboolean
If true the component uses its child only without the component template. Like Radix UI asChild or Base UI render props.
No
-
classstring
The CSS class(es) to be applied to the component.
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
No
[]

Machine JavaScript API

NameTypeDescription
portalledbooleanWhether the popover is portalled.
openbooleanWhether the popover is open
setOpen(open: boolean) => voidFunction to open or close the popover
triggerValuestring | nullThe trigger value
setTriggerValue(value: string | null) => voidFunction to set the trigger value
reposition(options?: Partial<PositioningOptions>) => voidFunction to reposition the popover

Accessibility

KeyDescription
SpaceOpens/closes the popover.
EnterOpens/closes the popover.
TabMoves focus to the next focusable element within the content.
Note: If there are no focusable elements, focus is moved to the next focusable element after the trigger.
Shift + TabMoves focus to the previous focusable element within the content
Note: If there are no focusable elements, focus is moved to the trigger.
EscCloses the popover and moves focus to the trigger.

Anatomy

<primitives:popover.root>
    <primitives:popover.trigger />
    <primitives:popover.positioner>
        <primitives:popover.content>
            <primitives:popover.arrow />
            <primitives:popover.closeTrigger />
            <primitives:popover.title />
            <primitives:popover.description />
        </primitives:popover.content>
    </primitives:popover.positioner>
</primitives:popover.root>