function App() {const [isOpen, setIsOpen] = useState(false)const handleOpen = () => {setIsOpen(true)}const handleClose = () => {setIsOpen(false)}return (<PopoverisOpen={isOpen}onClose={handleClose}onOpen={handleOpen}placement="bottom"size="md"trigger={(triggerProps) => {return (<Button {...triggerProps}><ButtonText>Popover</ButtonText></Button>)}}><PopoverBackdrop /><PopoverContent><PopoverHeader><Heading size="lg">Welcome!</Heading><PopoverCloseButton><Icon as={CloseIcon} /></PopoverCloseButton></PopoverHeader><PopoverBody><Text size="sm">Join the product tour and start creating your own checklist. Are youready to jump in?</Text></PopoverBody><PopoverFooter><Text size="xs" flex={1}>Step 2 of 3</Text><ButtonGroup space="md"><Button variant="outline" action="secondary" onPress={handleClose}><ButtonText>Back</ButtonText></Button><Button onPress={handleClose}><ButtonText>Next</ButtonText></Button></ButtonGroup></PopoverFooter></PopoverContent></Popover>)}
function App() {const [isOpen, setIsOpen] = useState(false)const handleOpen = () => {setIsOpen(true)}const handleClose = () => {setIsOpen(false)}return (<PopoverisOpen={isOpen}onClose={handleClose}onOpen={handleOpen}placement="bottom"size="md"trigger={(triggerProps) => {return (<Button {...triggerProps}><ButtonText>Popover</ButtonText></Button>)}}><PopoverBackdrop /><PopoverContent><PopoverArrow /><PopoverHeader><Heading size="lg">Welcome!</Heading><PopoverCloseButton><Icon as={CloseIcon} /></PopoverCloseButton></PopoverHeader><PopoverBody><Text size="sm">Join the product tour and start creating your own checklist. Are youready to jump in?</Text></PopoverBody><PopoverFooter><Text size="xs" flex={1}>Step 2 of 3</Text><ButtonGroup space="md"><Button variant="outline" action="secondary" onPress={handleClose}><ButtonText>Back</ButtonText></Button><Button onPress={handleClose}><ButtonText>Next</ButtonText></Button></ButtonGroup></PopoverFooter></PopoverContent></Popover>)}
import {Popover,PopoverBackdrop,PopoverContent,PopoverArrow,PopoverHeader,PopoverCloseButton,PopoverBody,PopoverFooter,} from "@darden/design-system"
export default () => (<Popover><PopoverBackdrop /><PopoverContent><PopoverArrow /><PopoverHeader><PopoverCloseButton /></PopoverHeader><PopoverBody /><PopoverFooter /></PopoverContent></Popover>)
Prop | Type | Default | Description |
---|---|---|---|
defaultIsOpen | boolean | - | Specifies the default open state of the popover. |
isOpen | boolean | - | If true, the popover will open. Useful for controllable state
behavior. |
trapFocus | boolean | true | Whether popover should trap focus. |
focusScope | boolean | true | Whether focus should be outside of popover or not |
shouldFlip | boolean | true | Whether the element should flip its orientation (e.g. top to
bottom or left to right) when there is insufficient room for it to
render completely. |
initialFocusRef | React.RefObject<any> | - | The ref of element to receive focus when the popover opens. |
finalFocusRef | React.RefObject<any> | - | The ref of element to receive focus when the popover closes |
trigger | () => any | - | Function that returns a React Element. This element will be used
as a Trigger for the popover. |
crossOffset | number | - | The additional offset applied along the cross axis between the
element and its trigger element. |
offset | number | - | The additional offset applied along the main axis between the
element and its trigger element. |
shouldOverlapWithTrigger | boolean | false | Determines whether popover content should overlap with the
trigger. |
isKeyboardDismissable | boolean | - | If true, the keyboard can dismiss the popover. |
placement | 'top' | 'top left' | 'top right' | 'bottom' | 'bottom left' |
'bottom right' | 'right' | 'right top' | 'right bottom' | 'left' |
'left top' | 'left bottom' | 'bottom' | Popover placement |
useRNModal | boolean | false | If true, renders react-native native modal. |
avoidKeyboard | boolean | - | If true, the popover will avoid the keyboard. |
onOpen | () => any | - | This function will be invoked when popover is opened. |
onClose | () => any | - | This function will be invoked when popover is closed. It'll also
be called when user attempts to close the popover via Escape key
or backdrop press. |
children | any | - | The content to display inside the popover. |
Sx Prop | Description |
---|---|
_content | Prop to style PopoverContent Component |
Sx Prop | Description |
---|---|
_text | Prop to style PopoverCloseButton Text Component |
_icon | Prop to style PopoverCloseButton Icon Component |
Name | Value | Default |
---|---|---|
size | xs | sm | md | lg | full | md |
<Box h="$80">{/* PhoneIcon, Clock3Icon, MailIcon are imported from 'lucide-react-native' */}<Popovertrigger={(triggerProps) => {return (<HStack><Pressable borderRadius="$full" {...triggerProps}><Avatar bg="$indigo600"><AvatarFallbackText>Kevin James</AvatarFallbackText></Avatar></Pressable><VStack ml="$2.5"><Heading fontSize="$md">Kevin James</Heading><Text size="sm">Hi Rachel, What’s up?</Text></VStack></HStack>)}}><PopoverBackdrop /><PopoverContent w="$80"><PopoverHeader px="$5" pt="$5"><HStack><Avatar bg="$indigo600"><AvatarFallbackText>Kevin James</AvatarFallbackText></Avatar><VStack ml="$2.5"><Heading fontSize="$md">Kevin James</Heading><HStack alignItems="center"><CircleIcon color="$green700" h="$2" w="$2" /><Text size="sm" pl="$1.5">Active</Text></HStack></VStack></HStack></PopoverHeader><PopoverBody px="$5" pb="$5"><VStack space="lg"><VStack space="sm"><HStack alignItems="center"><Icon as={PhoneIcon} size="sm" /><Text size="sm" ml="$1.5">(603) 555-0123</Text></HStack><HStack alignItems="center"><Icon as={Clock3Icon} size="sm" /><Text size="sm" ml="$1.5">5:21 PM local time</Text></HStack><HStack alignItems="center"><Icon as={MailIcon} size="sm" /><Text size="sm" ml="$1.5">kevinjames@sample.com</Text></HStack></VStack><Button bg="$darkBlue700" $dark-bg="$darkBlue500"><ButtonText>View Profile</ButtonText></Button></VStack></PopoverBody></PopoverContent></Popover></Box>