Feedback
Dialog
A dialog stops the person with one question that needs an answer before they go on, such as skipping an item or deleting a file.
In kanso-ui as Dialog
Web and native
Dialog in kanso-ui 0.59.0, for React.
import { Dialog } from '@kanso-labs/kanso-ui'A modal dialog centred over the page that fills the window below the medium breakpoint.
It pairs the Material Design dialogs page's basic and full-screen dialogs by window size, as the page does: above 600px a container on surface container high with a 28dp corner, 280–560px wide and 24dp of padding; below it, square corners with a 56dp header and action bar. An alert dialog (role="alertdialog") stays the basic dialog at every width, since the page keeps full screen for tasks.
What you provide
- A
ButtonorIconButtonplaced directly insideDialog, which opens it. - A
Dialog.Contentholding the dialog's parts. ADialog.Titleis what names the dialog for assistive technology. - Buttons given
slot="close"anywhere inside the content close it. - A dialog nothing on the page opens leaves
Dialogout and passesisOpenandonOpenChangetoDialog.Contentdirectly.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — |
Also takes the props of Omit<DialogTriggerProps, 'children'>.
Parts
Dialog.Content— the dialog and the scrim behind it, portalled out of the page.Dialog.Header— the row holding the title and, optionally, a closeIconButton.Dialog.Title— the headline, in headline small (title large when full screen); names the dialog.Dialog.Body— the supporting content, in body medium. The only part that scrolls, so the header and actions stay put.Dialog.Footer— the actions, aligned to the trailing edge and wrapping onto another row when they do not fit.
Example
import { Button, Dialog, IconButton, Text } from '@kanso-labs/kanso-ui'
// CloseIcon: an SVG of your own, sized 24 and filled with currentColor.
<Dialog>
<Button variant="outlined">Open dialog</Button>
<Dialog.Content>
<Dialog.Header>
<Dialog.Title>Headline</Dialog.Title>
<IconButton aria-label="Close" slot="close"><CloseIcon /></IconButton>
</Dialog.Header>
<Dialog.Body>
<Text tone="muted" variant="bodyMedium">Supporting text explains what the dialog is asking.</Text>
</Dialog.Body>
<Dialog.Footer>
<Button slot="close" variant="text">Cancel</Button>
<Button slot="close" variant="text">Confirm</Button>
</Dialog.Footer>
</Dialog.Content>
</Dialog>The design’s classes
k-scrim, k-dialog, k-dialog__title, k-dialog__body, k-dialog__actions, with k-btn--text, k-btn--ink and k-btn--critical.
Maps to Dialog in kanso-ui and react-native-kanso-ui.