videorc/ui

Popover

A floating panel for a short task, on the popup tier of the float glass. An Anchor part lines it up with something other than its trigger.

Installation

$ pnpm dlx shadcn@latest add @videorc/popover

Usage

import {
  Popover,
  PopoverContent,
  PopoverDescription,
  PopoverHeader,
  PopoverTitle,
  PopoverTrigger,
} from "@/components/ui/popover";
<Popover>
  <PopoverTrigger render={<Button variant="secondary" />}>
    Add marker…
  </PopoverTrigger>
  <PopoverContent>
    <PopoverHeader>
      <PopoverTitle>Add a marker</PopoverTitle>
      <PopoverDescription>
        Marks this moment in the recording.
      </PopoverDescription>
    </PopoverHeader>
  </PopoverContent>
</Popover>

Anatomy

<Popover>
  <PopoverAnchor />
  <PopoverTrigger />
  <PopoverContent>
    <PopoverHeader>
      <PopoverTitle />
      <PopoverDescription />
    </PopoverHeader>
  </PopoverContent>
</Popover>

Examples

Anchor

PopoverAnchor wraps what the popover should line up with when that isn't the trigger: here the whole status bar, so the sound board opens over its end rather than over the small Sounds button. The trigger still opens and closes it.

On air 12:04

Theming

Token or attributeMeaning
glass-floatThe popup tier: the window's solid tone, a 1 px rim and the float drop
rounded-lgThe popup tier's 10 px corners
w-72, p-3, gap-3Its default width and spacing
data-open, data-closedFades and scales from 0.98 in 100 ms, with no slide
data-side, data-alignWhere it opened

Keyboard

KeyAction
Enter, SpaceOn the trigger, opens or closes the popover
TabMoves through the popover's controls
EscapeCloses the popover and returns focus to the trigger

Accessibility

The popover is a dialog: PopoverTitle names it and PopoverDescription describes it. Focus moves into it on open and back to the trigger on close.

API reference

Every Base UI Popover prop, plus:

PopoverContent

Prop

Type

PopoverAnchor

Prop

Type