Skip to content

Popover Primitive

Dynamic content within a portal, activated by a button press.

Installation

Install the component via your command line.

Terminal window
npx expo install @rn-primitives/popover

Usage

import * as PopoverPrimitive from '@rn-primitives/popover';
import { Text } from 'react-native';
function Example() {
return (
<PopoverPrimitive.Root>
<PopoverPrimitive.Trigger>
<Text>Open Popover</Text>
</PopoverPrimitive.Trigger>
<PopoverPrimitive.Portal>
<PopoverPrimitive.Content>
<Text>Popover Content</Text>
</PopoverPrimitive.Content>
</PopoverPrimitive.Portal>
</PopoverPrimitive.Root>
);
}

Props

Root

Extends View props

PropTypeNote
asChildboolean(optional)
onOpenChange(value: boolean) => void(optional)

Trigger

Extends Pressable props

PropTypeNote
asChildboolean(optional)

TYPE: PopoverTriggerRef

MethodsargsNote
openopens the popover
closecloses the popover

Overlay

Extends Pressable props

PropTypeNote
asChildboolean(optional)
forceMounttrue | undefined;(optional)
closeOnPressboolean(optional)

Portal

PropTypeNote
children*React.ReactNode
forceMounttrue | undefined(optional)
hostNamestringWeb Only (optional)
containerHTMLElement | null | undefinedWeb Only (optional)

Content

Extends View props

PropTypeNote
asChildboolean(optional)
forceMounttrue | undefined(optional)
alignOffsetnumberNative Only (optional)
insetsInsetsNative Only (optional)
avoidCollisionsbooleanNative Only (optional)
align’start’ | ‘center’ | ‘end’Native Only (optional)
side’top’ | ‘bottom’Native Only (optional)
sideOffsetnumberNative Only (optional)
disablePositioningStylebooleanNative Only (optional)
onOpenAutoFocus(ev: Event) => voidWeb Only (optional)
onCloseAutoFocus(ev: Event) => voidWeb Only (optional)
onEscapeKeyDown(ev: Event) => voidWeb Only (optional)
onInteractOutside(ev: Event) => voidWeb Only (optional)
onPointerDownOutside(ev: Event) => voidWeb Only (optional)

Close

Extends Pressable props

PropTypeNote
asChildboolean(optional)

useRootContext

Must be used within a Root component. It provides the following values from the dialog: open, and onOpenChange.