Displays floating content in relation to a trigger element when clicked.
import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover" import { Button } from "@/components/ui/button" export function PopoverDemo() { return ( <Popover> <PopoverTrigger asChild> <Button variant="outline">Open popover</Button> </PopoverTrigger> <PopoverContent className="w-80"> <div className="grid gap-4"> <div className="space-y-2"> <h4 className="font-medium leading-none">Dimensions</h4> <p className="text-sm text-muted-foreground"> Set the dimensions for the layer </p> </div> <div className="grid gap-2"> <div className="grid grid-cols-3 items-center gap-4"> <Label htmlFor="width">Width</Label> <Input id="width" defaultValue="100%" className="col-span-2 h-8" /> </div> </div> </div> </PopoverContent> </Popover> ) }
Prop | Type | Default | Description |
---|---|---|---|
defaultOpen | boolean | - | The open state of the popover when it is initially rendered. |
open | boolean | - | The controlled open state of the popover. |
onOpenChange | function | - | Event handler called when the open state of the popover changes. |
modal | boolean | false | Whether the popover should trap focus when opened. |