Skip to content

Popover

Popover Primitive Text Component

Demo


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

Installation

Terminal window
npx @react-native-reusables/cli@latest add popover

Usage

import * as React from 'react';
import { Platform, View } from 'react-native';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
import { Button } from '~/components/ui/button';
import { Popover, PopoverContent, PopoverTrigger } from '~/components/ui/popover';
import { Text } from '~/components/ui/text';
function Example() {
const insets = useSafeAreaInsets();
const contentInsets = {
top: insets.top,
bottom: insets.bottom,
left: 12,
right: 12,
};
return (
<View className='flex-1 justify-center items-center p-6'>
<Popover>
<PopoverTrigger asChild>
<Button variant='outline'>
<Text>Open popover</Text>
</Button>
</PopoverTrigger>
<PopoverContent
side={Platform.OS === 'web' ? 'bottom' : 'top'}
insets={contentInsets}
className='w-80'
>
<Text className='font-medium leading-none native:text-xl'>Dimensions</Text>
<Text className='text-sm text-muted-foreground'>
Set the dimensions for the layer.
</Text>
</PopoverContent>
</Popover>
</View>
);
}

Props

Popover

Extends View props

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

PopoverTrigger

Extends Pressable props

PropTypeNote
asChildboolean(optional)

PopoverContent

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)