Unlock faster development with Fidely UI Pro components Coming soon

Popover

Used to show contextual information inside a popup when triggered

Usage

import { Popover } from '@fidely-ui/react'
<Popover.Root>
  <Popover.Trigger />
  <Popover.Positioner>
    <Popover.Content>
      <Popover.CloseTrigger />

      <Popover.Arrow>
        <Popover.ArrowTip />
      </Popover.Arrow>

      <Popover.Title />
      <Popover.Description />
    </Popover.Content>
  </Popover.Positioner>
</Popover.Root>

Examples

Controlled

Use the open and onOpenChange props to control the visibility of the popover.

Placement

Use the positioning.placement prop to configure the underlying Floating UI positioning logic, allowing you to control where the popover appears relative to its trigger.

Offset

Use the positioning.offset prop to adjust the position of the popover content.

Form and CloseTrigger

Custom Background

Use the --popover-bg CSS variable to change the background color of the Popover.Content and its arrow.

Within Dialog

To use the Popover within a Dialog, you need to avoid portalling the Popover.Positioner to the document's body.

/* <Portal> */
<Popover.Positioner>
  <Popover.Content>{/* ... */}</Popover.Content>
</Popover.Positioner>
/* </Portal> */

If the dialog uses scrollBehavior="inside":

  • Set the popover positioning strategy to fixed to prevent clipping.

  • Enable hideWhenDetached to hide the popover when its trigger scrolls out of view.

<Popover.Root positioning={{ strategy: 'fixed', hideWhenDetached: true }}>
  ...
</Popover.Root>

Props

Root

PropDefaultTypeDescription
autoFocustruebooleanWhether to automatically set focus on the first focusable content within the popover when opened.
closeOnEscapetruebooleanWhether to close the popover when the escape key is pressed.
asReact.ElementTypeThe underlying element to render. We don't recommend changing the input to another ElementType.
asChildfalsebooleanUse the provided child element as the default rendered element, combining their props and behavior.
closeOnInteractOutsidetruebooleanWhether to close the popover when the user clicks outside of the popover.
lazyMountfalsebooleanWhether to enable lazy mounting.
modalfalsebooleanWhether the popover should be modal. When true, interaction with outside elements will be disabled.
portalledtruebooleanWhether the popover is portalled. This proxies tabbing behavior regardless of the DOM position.
skipAnimationOnMountfalsebooleanWhether to allow the initial presence animation.
unmountOnExitfalsebooleanWhether to unmount on exit.
unstyledbooleanWhether to remove the component's default styles.
defaultOpenbooleanThe initial open state of the popover when rendered (uncontrolled).
idstringThe unique identifier.
idsPartial<{}>The ids of the elements in the popover.
immediatebooleanWhether to synchronize the present change immediately or defer it to the next frame.
initialFocusEl() => HTMLElement | nullThe element to focus on when the popover is opened.
onEscapeKeyDown(event: KeyboardEvent) => voidFunction called when the escape key is pressed.
onExitCompleteVoidFunctionFunction called when the animation ends in the closed state.
onFocusOutside(event: FocusOutsideEvent) => voidFunction called when the focus is moved outside the component.
onInteractOutside(event: InteractOutsideEvent) => voidFunction called when an interaction happens outside the component.
onOpenChange(details: OpenChangeDetails) => voidFunction invoked when the popover opens or closes.
onPointerDownOutside(event: PointerDownOutsideEvent) => voidFunction called when the pointer is pressed down outside the component.
onRequestDismiss(event: LayerDismissEvent) => voidFunction called when this layer is closed due to a parent layer being closed.
openbooleanThe controlled open state of the popover.
persistentElements(() => Element | null)[]Returns the persistent elements that should not have pointer-events disabled or trigger the dismiss event.
positioningPositioningOptionsThe user provided options used to position the popover content.
presentbooleanWhether the node is present (controlled by the user).

On this page