VisorVisor
ComponentsOverlay

Popover

A floating panel that appears next to a trigger element. Built on Radix UI with configurable alignment, offset, and controlled state support.

Basic Popover

Alignment Variants

Use the align prop on PopoverContent to align the panel relative to the trigger.

Side Positioning

Use the side prop to control which side of the trigger the panel opens on.

With Form Content

Popovers are commonly used to contain small forms or settings panels.

Controlled State

Use open and onOpenChange to fully control when the popover is shown.

import { useState } from 'react';
import { Popover, PopoverTrigger, PopoverContent } from '@/components/ui/popover/popover';
import { Button } from '@/components/ui/button/button';

export default function ControlledPopover() {
  const [open, setOpen] = useState(false);

  return (
    <Popover open={open} onOpenChange={setOpen}>
      <PopoverTrigger asChild>
        <Button variant="outline">{open ? 'Close' : 'Open'}</Button>
      </PopoverTrigger>
      <PopoverContent>
        <p style={{ margin: 0 }}>Controlled popover content.</p>
        <Button size="sm" onClick={() => setOpen(false)} style={{ marginTop: '0.75rem' }}>
          Dismiss
        </Button>
      </PopoverContent>
    </Popover>
  );
}

Stay Mounted

Pass forceMount to PopoverContent and the panel stays mounted: it renders in place, right after its trigger, and fades in and out instead of mounting on open. Focus stays on the trigger when it opens, so Tab walks into the panel. While closed, the panel is inert, so the keyboard and screen readers skip it. Escape and an outside click close it, and focus returns to the trigger when it was inside the panel.

Menu rows are ghost Buttons. Inside a stay-mounted panel they draw a soft tint of the ink (the glass layer's control fill over a photo) instead of the theme's solid ghost fill, so they sit inside the panel. Stack them with a gap, as below, so the rows never touch.

The panel renders in place, so side, align and sideOffset do nothing: place it with your own class (top, right, width) against a positioned ancestor. Because it is mounted with the page, images inside it load with the page even with loading="lazy"; set their src when the panel opens if that matters.

Skin and Glass

A theme reshapes the panel through the popover hooks: corners, inset, fill and shadow, plus the stay-mounted fade's length, curve and rise, and the menu rows' fill at rest and on hover. Each falls back to the look above, so a theme that binds none of them draws Popover unchanged. The full list is on Component Tokens.

components:
  popover:
    radius: "24px"
    padding: "10px"
    duration: "250ms"
    rise: "6px"

Glass is off by default. Inside data-glass="on" (see Glass), the panel takes the glass layer's fill, blur, shadow and ink. Everywhere else it is solid, with no blur. A bound bg or shadow wins in every look, so a theme can keep a denser menu fill over a photo. Only a stay-mounted panel can turn to glass: a portaled popover renders at the end of the page, outside the glass switch.

Under prefers-reduced-motion: reduce the panel still fades but does not rise.

In Five Looks

The account menu, open, in each look on the theme picked in the docs. The Photo looks turn glass on over a photo.

Today
Dark
Dark + Photo
Light
Light + Photo

Installation

npx visor add popover

This copies two files into your project:

  • components/ui/popover/popover.tsx — the component
  • components/ui/popover/popover.module.css — the styles

Usage

import {
  Popover,
  PopoverTrigger,
  PopoverContent,
} from '@/components/ui/popover/popover';
import { Button } from '@/components/ui/button/button';

export default function Example() {
  return (
    <Popover>
      <PopoverTrigger asChild>
        <Button variant="outline">Open</Button>
      </PopoverTrigger>
      <PopoverContent>
        <p>Place content here.</p>
      </PopoverContent>
    </Popover>
  );
}

API Reference

PopoverProps

PropTypeDefaultDescription
openboolean—Controlled open state of the popover.
onOpenChange(open: boolean) => void—Callback when the open state changes.
defaultOpenbooleanfalseDefault open state for uncontrolled usage.
side'top' | 'right' | 'bottom' | 'left''bottom'Side of the trigger the popover appears on (on PopoverContent).
align'start' | 'center' | 'end''center'Alignment of the popover content relative to the trigger (on PopoverContent).
sideOffsetnumber4Distance in pixels between the trigger and the popover (on PopoverContent).
asChildbooleanfalseOn PopoverTrigger — merges props onto the immediate child element instead of rendering a <button>.
classNamestring—Additional CSS class names to merge onto PopoverContent.

Sub-components

ComponentElementPurpose
PopoverRootContext provider (wraps Radix Popover.Root)
PopoverTrigger<button>The element that opens the popover; use asChild to wrap a custom trigger
PopoverContentFloating panelThe popover panel; accepts side, align, and sideOffset. forceMount keeps it mounted in place (see Stay Mounted)
PopoverAnchorAny elementOptional anchor to position the popover relative to a different element than the trigger

Accessibility

  • Built on Radix UI Popover — role="dialog" and aria-expanded are applied automatically.
  • Focus moves into the popover when it opens and returns to the trigger when it closes. With forceMount, focus stays on the trigger when it opens, the closed panel is inert, and focus returns to the trigger on close when it was inside the panel.
  • Pressing Escape closes the popover.
  • Clicking outside the popover closes it.
  • For non-modal popovers containing only non-interactive content (e.g., tooltips), consider HoverCard instead.