Popup
A popup displays brief content in an overlay.
Install
One package and one stylesheet. The stylesheet carries the tokens every component reads.
pnpm add @wolf-rayet/reactimport '@wolf-rayet/react/css/wolf-rayet.css';
import { Popup } from '@wolf-rayet/react';Props
A required prop is marked with an asterisk.
| Prop | Type | Default | Description |
|---|---|---|---|
| isOpen * | boolean | — | Whether the popup is shown. The open state belongs to you. |
| onClose * | () => void | — | Called on Escape and on a click outside. |
| trigger * | (props: { 'aria-expanded': boolean; 'aria-haspopup': true; onClick: () => void }) => ReactNode | — | A function returning the element the popup hangs off. The props it is given must be spread onto that element, because they carry the expanded state. |
| content * | ReactNode | — | What appears in the surface. |
| placement | 'bottom-start' | 'bottom-end' | 'top-start' | 'top-end' | 'bottom-start' | Which corner it opens from. It flips when there is no room. |
| isDialog | boolean | — | Pads the surface for prose. Leave it off for a menu, which brings its own padding. |
| label | string | — | Names the surface for assistive technology when it holds a dialog rather than a menu. |
Accessibility
What the component does for you, and what it needs from you.
- The props handed to the trigger carry the expanded state and must be spread onto it, or the button never announces that it opens something.
- Escape closes the popup and focus goes back to the trigger.
- Focus stays inside while it is open, so a keyboard reader does not fall through to the page behind.
- The surface shadow gains a hairline ring in dark, because a shadow alone does not separate it from the page there.