Popover is a non-modal dialog that floats around its disclosure. It's commonly used for displaying additional rich content on top of something.
NextUI exports 3 popover-related components:
- Popover: The main component to display a popover.
- PopoverTrigger: The component that triggers the popover.
- PopoverContent: The component that contains the popover content.
To be sure that the popover exposes the correct title to assistive technologies, you should use the
titleProps prop on the
PopoverContent component. To use this prop, you must pass a function as a child.
Popover handles the focus within the popover content. It means that you can use the popover with
form elements without any problem. the focus returns to the trigger when the popover closes.
Note: You can add the
autoFocusprop to the first
Inputcomponent to focus it when the popover opens.
Popover component has a
backdrop prop to show a backdrop behind the popover. The backdrop can be
blur. The default value is
Popover offers a
motionProps property to customize the
Learn more about Framer motion variants here.
- base: The main popover slot, it wraps the popover content and contains the arrow as a pseudo-element (::before).
- trigger: The popover trigger slot, it has small styles to ensure the trigger works correctly.
- backdrop: The backdrop slot, it contains the backdrop styles.
- content: The content slot, it contains the popover content.
You can customize the
Popover component by passing custom Tailwind CSS classes to the component slots.
Popover has the following attributes on the
- data-open: When the popover is open. Based on popover state.
The placement of the popover. Based on
placementprop. The arrow element is positioned based on this attribute.
- data-focus: When the popover is being focused. Based on useFocusRing.
- data-focus-visible: When the popover is being focused with the keyboard. Based on useFocusRing.
- The trigger and popover are automatically associated semantically via ARIA.
- Content outside the popover is hidden from assistive technologies while it is open.
- The popover closes when interacting outside, or pressing the Escape key.
- Focus is moved into the popover on mount, and restored to the trigger element on unmount.
- The popover is positioned relative to the trigger element, and automatically flips and adjusts to avoid overlapping with the edge of the browser window.
- Scrolling is prevented outside the popover to avoid unintentionally repositioning or closing it.
|children*||The content of the popover. It's usually the ||-|
|size||The popover content font size.|
|color||The popover color theme.|
|radius||The popover border radius.|
|shadow||The popover shadow.|
|backdrop||The popover backdrop type.|
|placement||PopoverPlacement||The placement of the popover relative to its trigger reference.|
|state||The controlled state of the popover. See Overlay States||-|
|isOpen||Whether the popover is open by default (controlled).||-|
|defaultOpen||Whether the popover is open by default (uncontrolled).||-|
|offset(px)||The distance or margin between the reference and popper. It is used internally to create an offset modifier.|
|containerPadding(px)||The placement padding that should be applied between the element and its surrounding container.|
|crossOffset(px)||The additional offset applied along the cross axis between the element and its anchor element.|
|triggerType||Type of popover that is opened by the trigger.|
|showArrow||Whether the popover should have an arrow.|
|shouldFlip||Whether the popover should change its placement and flip when it's about to overflow its boundary area.|
|triggerScaleOnOpen||Whether the trigger should scale down when the popover is open.|
|shouldBlockScroll||Whether to block scrolling outside the popover.|
|isKeyboardDismissDisabled||Whether pressing the escape key to close the popover should be disabled.|
|shouldCloseOnBlur||Whether the popover should close when focus is lost or moves outside it.|
|motionProps||MotionProps||The props to modify the framer motion animation. Use the |
|portalContainer||The container element in which the overlay portal will be placed.|
|triggerRef||The ref for the element which the popover positions itself with respect to.||-|
|scrollRef||A ref for the scrollable region within the popover.|
|disableAnimation||Whether the popover is animated.|
|classNames||Allows to set custom class names for the popover slots.||-|
|onOpenChange||Handler that is called when the popover's open state changes.|
|shouldCloseOnInteractOutside||When user interacts with the argument element outside of the popover ref, return true if onClose should be called. This gives you a chance to filter out interaction with elements that should not dismiss the popover. By default, onClose will always be called on interaction outside the overlay ref.|
|onClose||Handler that is called when the popover should close.|
|children*||The popover trigger component, ensure the children passed is focusable. Users can tab to it using their keyboard, and it can take a ref. It is critical for accessiblity.||-|
|children||The content that is displayed when the trigger is pressed.||-|
type PopoverPlacement =| "top"| "bottom"| "right"| "left"| "top-start"| "top-end"| "bottom-start"| "bottom-end"| "left-start"| "left-end"| "right-start"| "right-end";
export type MotionProps = HTMLMotionProps<"div">; // @see https://www.framer.com/motion/