Dialog
The content of an overlay that people act on, such as a Popover or a Modal.
<script>
import Button from '@brumate/ui/Button.brm';
import Dialog from '@brumate/ui/Dialog.brm';
import DialogTrigger from '@brumate/ui/DialogTrigger.brm';
import Heading from '@brumate/ui/Heading.brm';
import Popover from '@brumate/ui/Popover.brm';
</script>
<DialogTrigger>
<Button class="ui-button">About</Button>
<Popover class="ui-popover" transition>
<Dialog class="ui-dialog">
<Heading slot="title" level=(4)>About this page</Heading>
<p>A dialog takes focus, and its title names it.</p>
<Button slot="close" class="ui-button">Close</Button>
</Dialog>
</Popover>
</DialogTrigger>
- It is a
dialog, or analertdialogwithrole="alertdialog". AHeadingwithslot="title"names it. - A
Buttonwithslot="close"closes the overlay around it. - When the overlay opens, focus moves to the element of the dialog with
autofocus, or to the dialog itself, so a screen reader reads its title.
DialogTrigger
Opens an overlay from a Button inside it.
- It holds a
Buttonand an overlay, such as aPopoveror aModal. The button getsaria-expandedandaria-controls, and a press toggles the overlay. It gets noaria-haspopup, as in React Aria, because screen readers read a popup button as a menu. isOpenis the state. See State.- It renders only its children.
- An overlay inside another one needs a
DialogTriggerof its own, or its ownisOpen.