Skip to content
Vertical Jump Designs-uiFront-End Studio
Get Pro

v3.9 is out.

Overlays

Popover

Free18.5 KB gzipped

Accessibility: WCAG 2.2 AA · No A or AA violations in light or dark mode · Keys: Enter, Space, Escape and 2 more · Full report

Import

tsx
import { Popover } from "@vjdesigns/vjdesigns-ui";

Importing only Popover adds about 18.5 KB of minified, gzipped JavaScript to your app (React not included). The stylesheet is shared by every component and loaded once: 75.1 KB gzipped.

Examples

Basic

A non-modal panel anchored to its trigger. It closes on Escape, an outside click, or when focus leaves it.

tsx
import { Popover } from "@vjdesigns/vjdesigns-ui";

export function Basic() {
  return (
    <Popover>
      <Popover.Trigger variant="outline" tone="neutral">
        What's new?
      </Popover.Trigger>
      <Popover.Content showArrow showClose>
        <Popover.Title>Version 1.1</Popover.Title>
        <Popover.Description>Command palette, tree view and a new Timeline layout. See the changelog for details.</Popover.Description>
      </Popover.Content>
    </Popover>
  );
}

With form

Popovers can hold interactive content, like a small form. placement picks the side.

tsx
import { Field, Flex, Input, Popover, Stack } from "@vjdesigns/vjdesigns-ui";

export function WithForm() {
  return (
    <Popover placement="bottom-start">
      <Popover.Trigger>Rename</Popover.Trigger>
      <Popover.Content size="sm">
        <form onSubmit={(event) => event.preventDefault()}>
          <Stack gap={3}>
            <Popover.Title level={3}>Rename file</Popover.Title>
            <Field label="File name">
              <Input defaultValue="launch-plan.pdf" />
            </Field>
            <Flex gap={2} justify="end">
              <Popover.Close variant="ghost" tone="neutral" size="sm">
                Cancel
              </Popover.Close>
              <Popover.Close size="sm" type="submit">
                Save
              </Popover.Close>
            </Flex>
          </Stack>
        </form>
      </Popover.Content>
    </Popover>
  );
}

Custom trigger

Any element can be the trigger with asChild.

tsx
import { Button, Popover } from "@vjdesigns/vjdesigns-ui";

export function CustomTrigger() {
  return (
    <Popover placement="top">
      <Popover.Trigger asChild>
        <Button variant="link">Why do we ask?</Button>
      </Popover.Trigger>
      <Popover.Content size="sm" showArrow>
        <Popover.Description>We use your birthday to verify your identity if you lose access to your account.</Popover.Description>
      </Popover.Content>
    </Popover>
  );
}

Accessibility

Use modal for short tasks that must be finished or dismissed: it traps Tab inside the popover and sets aria-modal="true". Popover.Title gives it a heading, and the close button is named.

tsx
import {
  Button,
  Field,
  Flex,
  Input,
  Popover,
  Stack,
} from "@vjdesigns/vjdesigns-ui";

export function Accessibility() {
  return (
    <Popover modal placement="bottom-start">
      <Popover.Trigger variant="outline" tone="neutral">
        Share
      </Popover.Trigger>
      <Popover.Content showClose>
        <Stack gap={3}>
          <Popover.Title>Share this file</Popover.Title>
          <Field label="Email address">
            <Input type="email" autoComplete="email" fullWidth />
          </Field>
          <Flex justify="end" gap={2}>
            <Popover.Close variant="ghost" tone="neutral">
              Cancel
            </Popover.Close>
            <Button>Send</Button>
          </Flex>
        </Stack>
      </Popover.Content>
    </Popover>
  );
}

Translated

The close button's name comes from the locale (Japanese here), and the popover keeps the language of the area that opened it.

tsx
import { Popover, LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ja from "@vjdesigns/vjdesigns-ui/locales/ja";

export function Translated() {
  return (
    <LocaleProvider locale="ja" messages={ja}>
      <Popover>
        <Popover.Trigger variant="outline" tone="neutral">
          新機能
        </Popover.Trigger>
        <Popover.Content showArrow showClose>
          <Popover.Title>バージョン 1.3</Popover.Title>
          <Popover.Description>32 言語に対応した翻訳機能が追加されました。</Popover.Description>
        </Popover.Content>
      </Popover>
    </LocaleProvider>
  );
}

Right to left

The first example again, inside a right-to-left LocaleProvider (Arabic). Layout, spacing and arrow icons mirror, and the components' built-in text is translated. The example's own text stays in English.

Basic

tsx
import { LocaleProvider } from "@vjdesigns/vjdesigns-ui";
import ar from "@vjdesigns/vjdesigns-ui/locales/ar";

// Basic is the "Basic" example above.
<LocaleProvider locale="ar" messages={ar}>
  <Basic />
</LocaleProvider>

API reference

Popover

Popover props
PropTypeDefault
children

Popover.Trigger, Popover.Content, and optionally Popover.Anchor.

ReactNode—
open

Controlled open state.

boolean—
defaultOpen

Initial open state when uncontrolled.

booleanfalse
onOpenChange

Called with the next open state whenever it changes.

(open: boolean) => void—
placement

Preferred side and alignment relative to the anchor. Flips when there isn't room.

"top""top-start""top-end""bottom""bottom-start""bottom-end""left""left-start""left-end""right""right-start""right-end""bottom"
offset

Gap between the anchor and the popover, in px. Defaults to 8, or 12 with showArrow.

number—
modal

Modal mode: traps Tab inside the popover and sets aria-modal="true". Use it for short, focused tasks that must be finished or dismissed.

booleanfalse
closeOnOutsidePress

Close when the user presses outside the popover, trigger, and anchor.

booleantrue
closeOnEscape

Close when the user presses Escape. Nested popovers close innermost first.

booleantrue
closeOnFocusOut

Close when keyboard focus moves outside the popover (non-modal only).

booleantrue
closeOnAnchorFocus

Close when focus moves to the Popover.Anchor (anywhere in it except the trigger), leaving focus there. For a picker anchored to a text field: clicking or tabbing back into the field puts the popup away. Works in modal mode too.

booleanfalse

Popover.Trigger

Popover.Trigger props
PropTypeDefault
childrenRequired

A single element (usually a Button or IconButton) to turn into the trigger, or plain content to render inside a library Button.

ReactNode—
asChild

Clone the single child instead of wrapping it in a Button. Defaults to true when children is a single element. The child must be a focusable button-like element that accepts ref, onClick, and aria-*.

boolean—
variant

Visual style. Inherits from a surrounding ButtonGroup.

"solid""soft""outline""ghost""link""inverse""solid"
tone

Semantic color. Inherits from a surrounding ButtonGroup.

"neutral""primary""accent""success""warning""danger""info""primary"
size

Control height, padding, and type size. Inherits from a surrounding ButtonGroup.

"sm""md""lg""md"
radius

Corner rounding. When omitted, uses --control-radius (pill).

"none""xs""sm""md""lg""xl""2xl""pill""pill"
startIcon

Decorative icon before the label. Hidden from assistive technology.

ReactNode—
endIcon

Decorative icon after the label. Hidden from assistive technology.

ReactNode—
fullWidth

Stretches the button to fill its container. Inherits from a surrounding ButtonGroup.

booleanfalse

Also accepts native <button> attributes, plus className, style and ref.

Popover.Anchor

Popover.Anchor props
PropTypeDefault
children

The element to position against. A single element is used as-is; other content is wrapped in a div.

ReactNode—
asChild

Clone the single child instead of wrapping it. Defaults to true when children is a single element.

boolean—

Also accepts native <div> attributes, plus className, style and ref.

Popover.Content

Popover.Content props
PropTypeDefault
children

The popover's content: usually a Popover.Title, Popover.Description, and a body.

ReactNode—
aria-label

Accessible name. Required when there is no Popover.Title (the title names the dialog through aria-labelledby otherwise).

string—
initialFocus

Element to focus when the popover opens: an element, a ref, or a function. A function runs after the content has rendered and been positioned, so it can pick a node inside the content (e.g. () => listRef.current?.querySelector("[aria-selected=true]")). Defaults to the first focusable element, then the popover itself.

FocusTarget—
initialFocusRef

Same as initialFocus, as a ref.

RefObject<HTMLElement | null>—
showArrow

Show a pointer arrow on the side facing the anchor.

booleanfalse
showClose

Show a "Close" icon button in the top-end corner.

booleanfalse
closeLabel

Accessible name of the showClose button.

string"Close"
size

Width preset and padding: sm 16rem, md 20rem, lg 30rem max width.

"sm""md""lg""md"
maxWidth

Custom max width (any CSS length, or px as a number). Overrides the size width.

CSSProperties["maxWidth"]—
container

Element to portal into.

HTMLElement | nulldocument.body

Also accepts native <div> attributes, plus className, style and ref.

Popover.Title

Popover.Title props
PropTypeDefault
level

Heading level. Pick it by document outline.

234562

Also accepts native <h2> attributes, plus className, style and ref.

Popover.Description

Also accepts standard HTML attributes, plus className, style and ref.

Popover.Close

Popover.Close props
PropTypeDefault
children

Button label, or a single element to turn into the close control.

ReactNode"Close"
asChild

Clone the single child instead of wrapping it in a Button. Defaults to true when children is a single element.

boolean—
variant

Visual style. Inherits from a surrounding ButtonGroup.

"solid""soft""outline""ghost""link""inverse""solid"
tone

Semantic color. Inherits from a surrounding ButtonGroup.

"neutral""primary""accent""success""warning""danger""info""primary"
size

Control height, padding, and type size. Inherits from a surrounding ButtonGroup.

"sm""md""lg""md"
radius

Corner rounding. When omitted, uses --control-radius (pill).

"none""xs""sm""md""lg""xl""2xl""pill""pill"
startIcon

Decorative icon before the label. Hidden from assistive technology.

ReactNode—
endIcon

Decorative icon after the label. Hidden from assistive technology.

ReactNode—
fullWidth

Stretches the button to fill its container. Inherits from a surrounding ButtonGroup.

booleanfalse

Also accepts native <button> attributes, plus className, style and ref.

See what changed in each version in the Changelog.

Accessibility report

Popover targets WCAG 2.2 AA. Below: a live axe-core audit of this page's examples, Lighthouse scores for the page in both modes, the accessibility behavior built into the component, and the checks only a person can do.

axe-core audit (live)

Running accessibility audit

Checking the examples above…

Lighthouse audit

Light mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Dark mode

Score 100

35 passed · 0 failed · 30 not applicable · 10 to check by hand

Lighthouse 13.5.0 audits the whole docs page (header and sidebar included), not just the examples, in English. Last run 11/27/2026. Some failed audits carry no weight in the score, so a page can score 100 and still list one.

Built-in behavior

Keyboard

Keyboard
KeyAction
EnterSpaceOn the trigger: opens or closes the popover.
EscapeCloses it and returns focus to the trigger.
TabNon-modal: from the last element, moves on to what follows the trigger and closes. Modal: wraps inside.
Shift+TabNon-modal: from the first element, returns to the trigger (stays open).

Roles and states

Roles and states
ElementRoleStates and properties
Popover.Contentdialogaria-modal when modal, aria-labelledby → title, aria-describedby → description
Triggerbuttonaria-haspopup="dialog", aria-expanded, aria-controls

Manual checks

Automated tools find roughly a third of accessibility issues. Test these in your app, with your content.

Manual accessibility checks
CheckWhat to testWCAG 2.2
KeyboardEvery action works with Tab, Shift+Tab, Enter, Space and the arrow keys, and focus never gets stuck.2.1.1 (A), 2.1.2 (A)
FocusFocus moves in a logical order, is always visible, and isn't hidden behind sticky headers.2.4.3 (A), 2.4.7 (AA), 2.4.11 (AA), 2.4.13 (AAA)
Screen readersNames, roles and states are announced correctly, and status changes are announced without moving focus.1.3.1 (A), 4.1.2 (A), 4.1.3 (AA)
ColorMeaning never depends on color alone; your own colors meet contrast in both modes.1.4.1 (A), 1.4.3 (AA), 1.4.11 (AA), 1.4.6 (AAA)
Zoom and reflowAt 200% text size and at 320px wide (400% zoom), nothing is cut off and no sideways scrolling is needed.1.4.4 (AA), 1.4.10 (AA), 1.4.12 (AA)
Pointer targetsClick and tap targets are at least 24×24px (44×44px for AAA), or spaced so they don't overlap.2.5.8 (AA), 2.5.5 (AAA)
MotionAnimations respect the reduced-motion setting.2.3.3 (AAA)