Skip to contentWolf-Rayet

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/react
import '@wolf-rayet/react/css/wolf-rayet.css';
import { Popup } from '@wolf-rayet/react';

Props

A required prop is marked with an asterisk.

PropTypeDefaultDescription
isOpen *booleanNoneWhether the dialog is shown. You control the open state.
onClose *() => voidNoneCalled on Escape and on a click outside.
trigger *(props: { 'aria-expanded': boolean; 'aria-haspopup': true; onClick: () => void }) => ReactNodeNoneA function that returns the element the dialog opens from. Spread the props it receives onto that element.
content *ReactNodeNoneThe 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.
isDialogbooleanNoneSet this for an inline dialog. It adds padding suited to text rather than to a menu.
labelstringNoneNames 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.