Skip to content
PrimitivesPopoverMenu

Popover

Floating panel on Base UI with the kit's surface, origin-aware motion and no animation when opened from the keyboard.

A rich popover that grows out of its trigger.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/popover.json

Usage

tsx
import {
  Popover,
  PopoverContent,
  PopoverDescription,
  PopoverTitle,
  PopoverTrigger,
} from "@/components/ui/chatcn/popover"

<Popover>
  <PopoverTrigger render={<Button variant="outline">Context</Button>} />
  <PopoverContent align="start" className="w-72 p-3">
    <PopoverTitle>Context window</PopoverTitle>
    <PopoverDescription>124,000 of 200,000 tokens used.</PopoverDescription>
  </PopoverContent>
</Popover>

Padding defaults to 4 px, the right inset for lists; pass className="p-3" for text. popupSurface and popupMotion are exported so other floating parts can match it exactly.

Parts

PartBase UI partNotes
PopoverPopover.Rootopen, defaultOpen, onOpenChange, modal (default false)
PopoverTriggerPopover.Triggerrender to use your own button, openOnHover
PopoverContentPortal, Positioner, Popupside (bottom), align (center), sideOffset (6), anchor, initialFocus, finalFocus
PopoverTitle, PopoverDescriptionTitle, DescriptionLabel the popup for assistive tech
PopoverClosePopover.CloseCloses it; render to use a Button

Keyboard

KeyAction
Enter, SpaceOpen from the trigger and focus the first control inside
TabMove through the popup, then out of it
EscClose and return focus to the trigger

Motion

  • 180 ms in with opacity, scale from 0.96 and 4 px toward the trigger; 140 ms out to 0.98.
  • Keyboard-opened and Esc-dismissed popovers skip the transition through data-instant.
  • Under reduced motion only the fade remains.