Inline dialog
An inline dialog is a small popup that holds a little information.
Install
One package and one stylesheet. The stylesheet holds the tokens every component uses.
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 | None | Whether the dialog is shown. You control the open state. |
| onClose * | () => void | None | Called on Escape and on a click outside. |
| trigger * | (props: { 'aria-expanded': boolean; 'aria-haspopup': true; onClick: () => void }) => ReactNode | None | A function that returns the element the dialog opens from. Spread the props it receives onto that element. |
| content * | ReactNode | None | The dialog content. A short paragraph, or a very small set of controls. |
| 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 | None | Set this for an inline dialog. It adds padding suited to text rather than to a menu. |
| label | string | None | Names the dialog for assistive technology. This matters more than for a menu, because the content is text. |
Accessibility
What the component does for you, and what it needs from you.
- An inline dialog is a dialog, so give it a label. Unlike a menu, it has no items for a screen reader to announce.
- Escape closes it and focus returns to the trigger.
- The trigger must receive the props the component gives it. Otherwise it does not announce that it opens something.