Design
Dialogs are used to capture information, complete actions or display detailed messages without leaving the current page.
Available dialog sizes:
Small dialogs are commonly used for messages, while medium and large dialogs are used to capture information or complete tasks. If you feel you need a larger dialog, consider using a Page Dialog or simply create a full-viewport view instead.
When the viewport is too small for the selected dialog size, the dialog will become a full-screen overlay.
In most cases a Dialog will have at least two buttons in the footer - a verb action and an icon button to close the Dialog:
When the Close button is the only control in the Dialog footer, it must have the full visible text 'Close':
Dialog vs Page Dialog
Dialogs are used for modal interactions which are layered over the current view.
Note there is also a Page Dialog, which is a non-modal dialog used without layering over an existing view.
Code
There are two parts to each Dialog:
- A trigger element (usually a button) used to open the Dialog
- The Dialog itself, with a heading, content and controls
Notes:
- The Dialog content has no spacing applied by default. For standard grid spacing wrap the dialog content in an
.ace-panel
element. - If using the HTML API, note the dialog's
aria-labelledby
attribute must match theid
attribute of theh2
inside the dialog header. - If you are managing state directly, note the
aria-hidden
attribute must be updated appropriately when showing and hiding.
Example | Element | Code |
---|---|---|
Dialog trigger | Any button or link can be used as a Dialog trigger. |
Attach an event to your trigger element, then use the Dialog's ID with the
|
Small dialogs are suitable for short messages. |
|
|
Medium and large dialogs are good for forms. |
Note that the dialog's
|
|
Dialog with footer submit buttons | In some cases the dialog will contain form elements and you need to use the buttons in the dialog footer to submit the form. To do this, the ACE form classes are applied using a DIV (essentially a shim to enable styles) and an unclassed FORM element is placed as the first child of DIALOG. |
|
JavaScript
Methods
Function | Arguments | Description | Example |
---|---|---|---|
init | elementSelector |
Binds all the events and polyfills to dialog element. Init is called by default after the initial page load, so this is only required if you generate a new Dialog that has not been initialised. |
ACE.Dialog.init('.ace-dialog'); |
open | elementSelector | Opens dialog | ACE.Dialog.open('#dialog'); |
close | elementSelector | Closes dialog | ACE.Dialog.close('#dialog'); |
destroy | elementSelector | Removes the event bindings. | ACE.Dialog.destroy('.ace-dialog'); |
Events
Event | Description | Example |
---|---|---|
ace-dialog-displayed | Fires when dialog is displayed |
|
ace-dialog-closed | Fires when dialog is closed |
|
Dependencies
- jQuery 1.10.2 http://jquery.com/
- HTML5 Dialog support: dialog-polyfill https://github.com/GoogleChrome/dialog-polyfill
- HTML5 custom events object: customeventpolyfill.js