Popover
A speech bubble with a candy tail. It lands like jelly out of whatever opened it, with two puffs where it sprang from and a spray of stars off the corner where its own star keeps twinkling. Close it and it leaves in a cloud. ぽんっ
Installation
❯ npx shadcn@latest add https://yan.moe/r/popover.jsonUsage
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"<Popover>
<PopoverTrigger asChild>
<Button>Open</Button>
</PopoverTrigger>
<PopoverContent>Anything can go in here.</PopoverContent>
</Popover>PopoverClose closes it from inside, and PopoverAnchor positions it against
something other than the trigger. For other bursts, pass a recipe from
Effects: <PopoverContent fx={fxRecipes.bubbles}>.
Accessibility
- Built on Radix Popover: focus moves into the card when it opens and returns to the trigger on Escape or an outside click.
- On a phone the card is never wider than the screen minus a 16px margin on each side.
- With
prefers-reduced-motion: reduce, the card appears without the bounce or the particles.
API
| Prop | Type | Default |
|---|---|---|
intensitySet on PopoverContent. kawaii: jelly landing, puffs, stars, a corner star and a cloud on close. subtle: fade in. off: just appear. | "kawaii" | "subtle" | "off" | "kawaii" |
fxSet on PopoverContent. Overrides for the burst when it opens (kawaii only). | BurstOptions | - |
hideArrowSet on PopoverContent. Hide the tail that points at the trigger. | boolean | false |
sideSet on PopoverContent. Preferred side. | "top" | "right" | "bottom" | "left" | "bottom" |
alignSet on PopoverContent. Alignment along that side. | "start" | "center" | "end" | "center" |
sideOffsetSet on PopoverContent. Gap between trigger and bubble, in px. | number | 12 |