Popover
Display rich content in a portal, triggered by a button.
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";
export default () => ( <Popover> <PopoverTrigger asChild> <Button variant="secondary">Open Popover</Button> </PopoverTrigger> <PopoverContent> <p>This is the content of the popover.</p> </PopoverContent> </Popover>);Titles
Section titled “Titles”To display a title, pass a title prop into <PopoverTitle>. You can also pass a FontAwesome icon and iconProps to display an icon.
import { Button } from "stylus-ui/Button";import { Popover, PopoverContent, PopoverTitle, PopoverTrigger,} from "stylus-ui/Popover";import { faInfoCircle } from "@fortawesome/pro-regular-svg-icons";
export default () => ( <Popover> <PopoverTrigger asChild> <Button variant="secondary">Open Popover</Button> </PopoverTrigger> <PopoverContent> <PopoverTitle title="Popover with icon" icon={faInfoCircle} /> <p>This popover has a title with an icon.</p> </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";
export default () => ( <Popover> <PopoverTrigger asChild> <Button variant="secondary">Open Popover</Button> </PopoverTrigger> <PopoverContent side="top" sideOffset={10} align="start"> <p>This popover is positioned on top and aligned to the start.</p> </PopoverContent> </Popover>);API Reference
Section titled “API Reference”Popover
Section titled “Popover”Wraps <PopoverTrigger> and <PopoverContent>.
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>.
PopoverTrigger
Section titled “PopoverTrigger”Inherits properties from HTMLButtonElement.
PopoverContent
Section titled “PopoverContent”Inherits properties from Radix HTMLElement.