Skip to content

Popover API

Cimpress UI exports two popover-related components:

  • PopoverRoot: component that connects a trigger button with its associated popover.
  • Popover: component that displays an overlay element positioned relative to a trigger.
import { Popover, PopoverRoot } from '@cimpress-ui/react';

While a popover is open, all content outside of it is hidden from assistive technologies.

Popovers can be closed by interacting outside or by pressing the Escape key.

Popover requires a textual label to remain accessible to assistive technologies. See our accessibility guide for more details.

To open a popover when a trigger button is pressed, wrap both the trigger button and the popover component with a PopoverRoot component. This will automatically associate the button with the popover, without any manual setup.

It’s also possible to display a popover programmatically (not as a result of a user action), or render it in a different part of the component tree than its trigger. In this case, you’ll have to manage the popover’s open state manually.

Popover can be closed programmatically by passing a function as children to the Popover component, and using the close function provided as an argument to that function.

Encapsulates a popover trigger and its associated popover. The trigger can be any Cimpress UI button, and the popover will be displayed when the trigger is activated.

PopoverRootProps
ReactNode

The popover trigger with its associated popover. Provide the trigger as the first child, and the popover as the second child.

boolean

Whether the popover is open (controlled).

boolean

Whether the popover is open by default (uncontrolled).

(isOpen: boolean) => void

Handler that is called when the popover's open state changes.

Displays an overlay element positioned relative to a trigger.

See popover usage guidelines.

Ref<HTMLElement>

The ref type for this component.

PopoverProps
ReactNode | ((renderProps: PopoverRenderProps) => ReactNode)

The contents of the popover. A function may be provided to access a function to close the popover.

string

The title of the popover.

boolean

Whether the popover is open (controlled). If using PopoverRoot, this prop has no effect - provide isOpen to PopoverRoot instead.

boolean

Whether the popover is open by default (uncontrolled). If using PopoverRoot, this prop has no effect - provide defaultOpen to PopoverRoot instead.

(isOpen: boolean) => void

Handler that is called when the popover's open state changes. If using PopoverRoot, this prop has no effect - provide onOpenChange to PopoverRoot instead.

RefObject<Element | null>

The ref for the element which the popover positions itself with respect to. When used within PopoverRoot, this is set automatically. Provide triggerRef only when Popover is used standalone.

string

The element's unique identifier. See MDN.

boolean

Use this attribute to "claim" the component tree for exclusive Cimpress UI usage.

string

Sets the CSS className for the element. Only use as a last resort. Use style props instead.

See styling guide.

CSSProperties

Sets the CSS style for the element. Only use as a last resort. Use style props instead.

See styling guide.

string

Defines a string value that labels the current element.

string

Identifies the element (or elements) that labels the current element.

string

Identifies the element (or elements) that describes the object.

string

Identifies the element (or elements) that provide a detailed, extended description for the object.

Placement

The placement of the element with respect to its anchor element.

Defaults to 'bottom' .