Skip to content

Overlay

Popover

Anchored panel opened by a trigger control.

import { Popover } from '@var-ui/react';

Popover

Click-triggered panel for short interactive content. Unlike Tooltip / HoverCard, it opens on press and can host actions. Popover is the compound Root (Popover.Trigger, Popover.Popup, Popover.Close, Popover.Title, Popover.Description, Popover.Content). The trigger child must forward DOM props (popovertarget) — there is no render prop.

The popup is a native <div popover="auto"> rendered in place: it sits in the top layer (so it works inside a modal <dialog>), is positioned with CSS anchor positioning and light-dismisses on an outside press or Escape. Pass placement (top, bottom, start, end, optionally with an alignment such as bottom end) and offset (px or any CSS length, written to --var-ui-popup-offset). There is no arrow part.

State attributes, anchor positioning variables, and onOpenChange reasons are documented in Overlay lifecycle.

Examples

Compound parts

Compose Trigger, Popup, Title and Content.

Demo.tsxTSX
import { Button, Popover } from '@var-ui/react';

<Popover>
  <Popover.Trigger>
    <Button>Open</Button>
  </Popover.Trigger>
  <Popover.Popup>
    <Popover.Title>Details</Popover.Title>
    <Popover.Content>
      <p>Popover body content.</p>
    </Popover.Content>
  </Popover.Popup>
</Popover>

With a title

The usual arrangement: a trigger, a titled popup and a content body.

Demo.tsxTSX
import { Button, Popover } from '@var-ui/react';

<Popover>
  <Popover.Trigger>
    <Button>Open</Button>
  </Popover.Trigger>
  <Popover.Popup>
    <Popover.Title>Details</Popover.Title>
    <Popover.Content>
      <p>Popover body content.</p>
    </Popover.Content>
  </Popover.Popup>
</Popover>

With actions

Put buttons or links in the body for lightweight confirm or follow-up flows without a full dialog.

Demo.tsxTSX
import { Button, HStack, Popover } from '@var-ui/react';

<Popover>
  <Popover.Trigger>
    <Button>Share</Button>
  </Popover.Trigger>
  <Popover.Popup>
    <Popover.Title>Share link</Popover.Title>
    <Popover.Content>
      <p>Anyone with the link can view this draft.</p>
      <HStack gap="sm" style={{ marginTop: '0.75rem' }}>
        <Button tone="accent" appearance="solid" size="sm">
          Copy link
        </Button>
        <Button tone="accent" appearance="ghost" size="sm">
          Cancel
        </Button>
      </HStack>
    </Popover.Content>
  </Popover.Popup>
</Popover>

Props

Accessibility

Built on the native popover attribute. The trigger is a popovertarget invoker, Escape and outside presses close it, and focus returns to the trigger on close. Opening does not move focus into the panel: put autofocus on an element inside it when it should take focus. The popup gets role="dialog" and an accessible name only when it has a Popover.Title or an aria-label. Keep content focused — for blocking decisions use AlertDialog or Dialog.