Skip to main content

An accessible popup anchored to a button.

<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>
typo3 ui:add popover

Read more about installing Components and Primitives.

Set showCloseButton on popover.content to add a close button in the corner.

Pass placement through the positioning prop. The popover below opens to the right of its trigger.

Set modal to trap focus and block interaction with the rest of the page while the popover is open.

The label of the close button comes from the library's language file and follows the site language. Override it per template with the translations prop:

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

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.

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. 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
[]
autoMountboolean
Whether the client initializes the component on its own. Set it to false to mount it yourself with `mount()`
No
true

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

NameDescriptionRequiredDefault
valuestring
No
-
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
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
-

Rendered data attributes

AttributeDescription
data-popover-trigger<uid>
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"

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

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
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
-

Rendered data attributes

AttributeDescription
data-popover-positioner<uid>
data-nestedPresent when the positioner is nested within another {{widget}}
data-has-nestedPresent when the positioner has nested {{widget}}s

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

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
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
-

Rendered data attributes

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

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

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
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
-

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

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
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
-

Rendered data attributes

AttributeDescription
data-popover-indicator<uid>
data-state"open" | "closed"

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

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
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
-

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

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
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
-

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

NameDescriptionRequiredDefault
attributesarray
Additional attributes that should be rendered on the component where ui:attributes is used.
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
-
NameTypeDescription
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
getTriggerState(props?: TriggerProps) => TriggerStateReturns the state of a specific trigger, including whether it's the currently active one
getPositionerState() => PositionerStateReturns the state of the positioner
getContentState() => ContentStateReturns the state of the content
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.