Dialog
A dialog holds a decision or a short task that people finish before going back to the page. It dims the page behind it and returns focus to the control that opened it.
When to use it
Welders for Split
This week
- Collect passport copiesAna8 Oct
- Book the medical checkMarko12 Oct
- Send contracts for signingAna14 Oct
- Order flight ticketsIvana20 Oct
- Register addresses in SplitMarko27 Oct
- Arrange the first day on siteIvana2 Nov
Open a dialog when the page cannot go on without an answer, such as before deleting a candidate, or for a short form such as adding a task.
If the action can be undone, do it at once and offer Undo in a toast. For details read beside the page, use a side sheet, and for a few controls on one item, a popover.
Anatomy
The body scrolls when it runs taller than the dialog, while the header and footer stay put. A thin line shows under the header or above the footer only while content hides behind it.
Add task
- Title
- 17 px on a 24 px line, weight 700
- Description
- 14 px on a 22 px line, 4 px below the title
- --type-small, --text-muted
- Close button
- 32 px, 44 px on touch screens
- Header padding
- 16 px top, 20 px left, 12 px right
- --space-4, --space-5, --space-3
- Body padding
- 8 px top, 20 px sides
- --space-2, --space-5
- Footer padding
- 16 px top and bottom, 20 px sides
- --space-4, --space-5
- Corner radius
- 16 px
- --radius-2xl
- Maximum height
- 92 percent of the window
Sizes
A dialog keeps at least 24 px from each side of the window. Below 640 px it opens as a bottom sheet, and a large one fills the screen.
Delete this candidate permanently?
Sunita Rai's CV, passport scan and interview notes are removed now and cannot be restored.
Small, 448 px
Confirmations and notices
Add task
Medium, 512 px
Forms
Welders for Split
12 welders from three countries
- Stage
- Medical checks
- Employer
- Velebit Build
- Arrival
- 2 November
- Contracts sent for signingToday, 09:40
- Medical checks booked for 12 weldersYesterday, 16:05
- Work permits filed with the ministry22 Sep, 11:20
- Passport copies collected18 Sep, 14:10
Large, 896 px
A record with its history
Actions and their order
Actions sit at the right end of the footer: Cancel first, the completing action last. The completing action takes the primary button, or the danger button when it deletes.
When they do not fit on one line, they stack at full width with the completing action on top.
A confirmation opens with focus on Cancel, so an Enter pressed out of habit keeps the data.
Delete this candidate permanently?
Sunita Rai's CV, passport scan and interview notes are removed now and cannot be restored.
Candidates
Sunita Rai
Care assistant, Pokhara
- Button height
- 36 px, 44 px on touch screens
- Gap between actions
- 8 px
- --space-2
- Actions in one footer
- at most three
Closing
Once something is typed, Escape, the close button and a click on the dimmed page first ask “Discard the changes?” Cancel never asks: its label already says what happens.
Focus then goes back to the control that opened the dialog, or, if the dialog removed it, to the next row, the previous one or the list.
- Escape
- closes it, and in a confirmation answers Cancel
- Close button
- closes it. A confirmation has none
- Click on the dimmed page
- closes it. A confirmation ignores it
Discard the changes?
Your changes are not saved yet.
Keyboard and focus
When a dialog opens, focus goes to the first field of a form, to Cancel in a confirmation, or to the dialog itself when it only shows content. The page behind stops scrolling and ignores the pointer, keys and screen readers.
- Tab, Shift+Tab
- next or previous control, wrapping at the ends
- Enter in a text field
- submits the form
Saving and errors
While the completing action waits for the server, its button is busy at once and shows a spinner after 300 ms. The rest of the dialog stays usable.
If a field is wrong, focus moves to the first field with an error. If saving fails, a message at the top of the body says so and the entries stay as typed.
While content loads, the header and footer show at once over a skeleton of the body.
Add task
Add task
The task was not added. Try again.
Content
The title names the task or asks the question. The body adds only what the title cannot hold, starting with the consequence. Buttons answer the title with a verb, plus a noun when the verb alone could mean two things.
Permitted
Delete this candidate permanently?
The question people answer.
Delete candidate
It repeats the verb of the title.
Not permitted
Are you sure?
It hides what is at stake.
OK
It names no action.
Accessibility
A dialog has role dialog, a confirmation role alertdialog, both with aria-modal. The title labels it, and a confirmation's body describes it, so a screen reader reads the question with its consequence.
The close button is named Close.