Skip to content

Popover Primitive

Types Primitives Hooks Primitives Slot Primitives Portal Primitives

@radix-ui/react-popover


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

Installation

Install @radix-ui/react-popover

Terminal window
npx expo install @radix-ui/react-popover

Copy/paste the following code for web to ~/components/primitives/popover/popover.web.tsx

Copy/paste the following code for native to ~/components/primitives/popover/popover.tsx

Copy/paste the following code for types to ~/components/primitives/popover/types.ts

Copy/paste the following code for exporting to ~/components/primitives/popover/index.ts

Usage

import * as PopoverPrimitive from '~/components/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)
openboolean(optional)
onOpenChange(value: boolean) => void(optional)
defaultOpenboolean(optional)

Trigger

Extends Pressable props

PropTypeNote
asChildboolean(optional)

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.