Skip to content

Popover

Pro

An anchored panel of any content, with managed focus and light dismiss, that fills the window on a phone. Not an M3 component (@windmorph/react-pro).

import { Popover, PopoverTrigger } from '@windmorph/react-pro';

Part of Windmorph Pro, paid components on the free core, not on sale yet. See the Pro guide for what it includes and to register interest.

Props

By name or description, across the 27 props below

Popover 23 props

  • childrentype ReactNodeRequired

    The panel's content.

  • placementtype "top" | "bottom" | "start" | "end" | "top-start" | "top-end" | "bottom-start" | "bottom-end" | "start-top" | "start-bottom" | "end-top" | "end-bottom"default "bottom-start"

    Where the panel opens beside its anchor.

  • offsettype numberdefault 4

    The gap between the anchor and the panel, px.

  • crossOffsettype numberdefault 0

    Shifts the panel along its anchor, px.

  • triggerReftype RefObject<HTMLElement | null>

    The element to anchor to, when the popover has no PopoverTrigger.

  • opentype boolean

    Whether it is open (controlled). Ignored inside a PopoverTrigger, which owns it.

  • defaultOpentype booleandefault false

    Whether it starts open, when uncontrolled.

  • closedBytype "any" | "closerequest" | "none"default "any"

    How a person may close it: any (a press outside, or Escape), closerequest (Escape only) or none (only the app).

  • fullScreenOnCompacttype booleandefault true

    Fill the window below 600px wide, with a header holding a close button.

  • modaltype booleandefault true

    Whether the rest of the page waits while it's open: focus stays inside, the page is hidden from assistive technology and a press outside only closes it. false makes it a non-modal dialog (WAI-ARIA), for a panel that works beside what it's anchored to (the emoji picker in a message field): the page stays usable and the anchor (triggerRef, else the PopoverTrigger's button) and the panel act as one. Focus or a press in the anchor keeps it open and Escape there closes it (unless a list it controls is open). The panel follows the trigger in Tab order: Tab goes from the trigger into the panel and from its last control to what follows the trigger, and Shift + Tab mirrors it, from what follows the trigger into the panel's last control and from its first back to the trigger. Since the panel is last in the page, Tab from the page's last control passes over it and leaves the page, and Shift + Tab coming back into the page goes to the page's last control outside it (into it only when nothing follows the trigger). Focus or a press anywhere else closes it. The full-screen form below 600px is always modal.

  • autoFocustype booleandefault true

    Focus the panel's first control as it opens. false focuses the panel itself, for content that decides its own first focus (a search box only with a fine pointer).

  • titletype ReactNodedefault the aria-label

    The full-screen header's text.

  • closeIcontype ReactElement<unknown, string | JSXElementConstructor<any>>

    Replaces the full-screen form's close icon.

  • reftype Ref<HTMLDivElement>

    Ref to the outermost element.

  • idtype string

    The outermost element's id.

Events

  • onOpenChangetype ((open: boolean) => void)

    Called when it opens or closes.

  • onClosedtype (() => void)

    Called when it has finished closing.

Text

  • labelstype Partial<PopoverLabels>

    Words it shows or announces. A LabelsProvider sets them for the whole app.

  • aria-labeltype string

    One of aria-label or aria-labelledby is required.

  • aria-labelledbytype string

    One of aria-label or aria-labelledby is required.

Also accepts the root element's HTML attributes (id, data-*, event handlers).

PopoverTrigger 4 props

  • childrentype ReactNodeRequired

    The trigger (any button-like component) followed by the Popover.

  • opentype boolean

    Whether it is open (controlled).

  • defaultOpentype booleandefault false

    Whether it starts open, when uncontrolled.

Events

  • onOpenChangetype ((open: boolean) => void)

    Called when it opens or closes.

Spec status

Not part of Material Design 3: a Windmorph Pro component, built on M3's colour roles, type scale, shapes and motion. Its variants and configurations each link to a live example.

  • An anchored panel of any content

    Built

    Use case · Account

  • A form that keeps what was typed (closedBy="closerequest")

    Built

    Configuration · Form

Theming & tokens

Set the tokens below on the panel or any ancestor, such as :root, since it renders in a portal. Style each part with classNames: root, panel, content, header, close.

Popover tokens
VariableDefaultPaints
--wm-popover-container-colorvar(--md-sys-color-surface-container)The panel’s surface.
--wm-popover-container-shapevar(--md-sys-shape-corner-large)The panel’s corners.
--wm-popover-container-elevationvar(--md-sys-elevation-level-2)The panel’s shadow.
--wm-popover-text-colorvar(--md-sys-color-on-surface)The content’s default text colour.
--wm-popover-padding16pxThe space around the content.
--wm-popover-min-width112pxThe least width of the panel.
--wm-popover-max-widthmin(480px, calc(100vw - 32px))The greatest width of the panel.
--wm-popover-max-heightmin(560px, calc(100dvh - 32px))The content’s greatest height, past which it scrolls.
--wm-popover-reveal-durationvar(--md-sys-motion-spring-spatial-fast-duration)How long the reveal from the anchored edge takes.
--wm-popover-reveal-easingvar(--md-sys-motion-spring-spatial-fast-easing)The easing of the reveal.
--wm-popover-fade-durationvar(--md-sys-motion-spring-effects-fast-duration)How long the fade takes; it stays under reduced motion.
--wm-popover-fade-easingvar(--md-sys-motion-spring-effects-fast-easing)The easing of the fade.