Popover
To create a popover, import and compose <Popover>, <PopoverTrigger>, and <PopoverContent>.
import { Button } from "stylus-ui/Button";import { Popover, PopoverContent, PopoverTrigger } from "stylus-ui/Popover";import { Text } from "stylus-ui/Text";
export default () => ( <Popover> <PopoverTrigger asChild> <Button variant="secondary">Open Popover</Button> </PopoverTrigger> <PopoverContent> <Text size="sm">This is the content of the popover.</Text> </PopoverContent> </Popover>);Positioning
Section titled “Positioning”Positioning of the popover can be modified with side, sideOffset, align, and alignOffset props.
import { Button } from "stylus-ui/Button";import { Popover, PopoverContent, PopoverTrigger } from "stylus-ui/Popover";import { Text } from "stylus-ui/Text";
export default () => ( <Popover> <PopoverTrigger asChild> <Button variant="secondary">Open Popover</Button> </PopoverTrigger> <PopoverContent side="top" sideOffset={10} align="start"> <Text size="sm"> This popover is positioned on top and aligned to the start. </Text> </PopoverContent> </Popover>);API Reference
Section titled “API Reference”Popover
Section titled “Popover”Displays rich content in a portal, triggered by a button.
defaultOpen
modal
onOpenChange
open
PopoverAnchor
Section titled “PopoverAnchor”An optional element to position the PopoverContent against. If this part is not used, the content will position alongside the PopoverTrigger.
asChild
virtualRef
PopoverTrigger
Section titled “PopoverTrigger”A button that opens a Popover.
asChild
PopoverContent
Section titled “PopoverContent”The content rendered when a Popover is opened after clicking a PopoverTrigger.
align
alignOffset
arrowPadding
asChild
avoidCollisions
collisionBoundary
collisionPadding
container
forceMount
Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
hideWhenDetached
onCloseAutoFocus
Event handler called when auto-focusing on close. Can be prevented.
onEscapeKeyDown
Event handler called when the escape key is down. Can be prevented.
onFocusOutside
Event handler called when the focus moves outside of the DismissableLayer.
Can be prevented.
onInteractOutside
Event handler called when an interaction happens outside the DismissableLayer.
Specifically, when a pointerdown event happens outside or focus moves outside of it.
Can be prevented.
onOpenAutoFocus
Event handler called when auto-focusing on open. Can be prevented.
onPointerDownOutside
Event handler called when the a pointerdown event happens outside of the DismissableLayer.
Can be prevented.