Skip to content

Popover

Download .md

A popover opens a small panel next to the button that opened it, for extra content or a short task that doesn’t need a dialog.

  • Use it to share a link, set a quick filter, or show details about one item.
  • Use a Tooltip for a one-line name of an icon button, and a Dialog for a task that needs the whole attention.
  • Use a Dropdown Menu for a list of actions.
React
Vue
123
  1. 1Trigger
  2. 2Arrow
  3. 3Content

A panel on popover with a border, radius-lg and shadow-lg, 288px wide by default, placed beside its trigger. It renders outside the page flow, so a card never clips it. A title and one sentence of description may head it.

There is one style. Choose the side (top, right, bottom, left) and the alignment (start, center, end).

React Vue Flutter Type Default Use
open / onOpenChange v-model:open controller boolean false Opens and closes it from code.
side on PopoverContent side on PopoverContent anchor text bottom Which side of the trigger it opens on.
align on PopoverContent align on PopoverContent anchor text center How it lines up with the trigger.
PopoverTrigger render PopoverTrigger as-child child element none The button that opens it.
import { useId } from "react"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { Label } from "@/components/ui/label"
import { Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger } from "@/components/ui/popover"
export default function PopoverDemo() {
const id = useId()
return (
<Popover>
<PopoverTrigger render={<Button variant="outline" />}>Bagikan</PopoverTrigger>
<PopoverContent>
<PopoverHeader>
<PopoverTitle>Bagikan rilis</PopoverTitle>
<PopoverDescription>Siapa pun yang punya tautan ini bisa mendengarkan.</PopoverDescription>
</PopoverHeader>
<div className="grid gap-2">
<Label htmlFor={`${id}-link`}>Tautan rilis</Label>
<div className="flex gap-2">
<Input id={`${id}-link`} readOnly defaultValue="https://contoh.id/senja-di-kota" />
<Button>Salin</Button>
</div>
</div>
</PopoverContent>
</Popover>
)
}
Terminal window
npx shadcn@latest add https://design.sosialoka.tech/r/react/popover.json
  • The panel is a dialog that takes the focus when it opens and gives it back to the trigger when it closes.
  • Escape and a click outside close it.
  • Give the trigger a clear name, such as “Bagikan”.