Default

Achieved using variant="default".

Default Dialog

This dialog was created from markup. Dialogs can also be created with JavaScript.

Show Markup

                  

Error

Achieved using variant="error".

Error Dialog

This dialog was created from markup. Dialogs can also be created with JavaScript.

Show Markup

                  

Warning

Achieved using variant="warning".

Warning Dialog

This dialog was created from markup. Dialogs can also be created with JavaScript.

Show Markup

                  

Success

Achieved using variant="success".

Success Dialog

This dialog was created from markup. Dialogs can also be created with JavaScript.

Show Markup

                  

Help

Achieved using variant="help".

Help Dialog

This dialog was created from markup. Dialogs can also be created with JavaScript.

Show Markup

                  

Info

Achieved using variant="info".

Info Dialog

This dialog was created from markup. Dialogs can also be created with JavaScript.

Show Markup

                  

JS Class Initialization

Use the Coral.Dialog constructor to instantiate a Coral.Dialog.

                    

No example content provided!

Show a Coral.Dialog

The following is an example of how to show a Coral.Dialog.

                    

No example content provided!

Handling user interaction

To prevent a dialog from being hidden (for example, until a form passes validation), call event.preventDefault() in any listener to the coral-overlay:beforeclose event.

Open and close the dialog using the "Show a Dialog" example above to see logged events.

                    

No example content provided!

Log

Handling user interaction programmatically

Create a Coral.Dialog with two buttons in the footer.

The Cancel button will have the [coral-close] attribute so it dismisses the dialog.

The Accept button will have a specific ID that we'll listen for clicks on.

                    

No example content provided!

Listen for the coral-overlay:close event to know when the dialog has been dismissed.

Listen for the click event on the accept button to know when the user wants to proceed.

                    

No example content provided!

Log

Keyboard Controls

When the modal is visible, pressing the escape key will dismiss the top most modal.

Focus Behavior

When shown, the modal will focus on itself, showing no border. Pressing Tab will move to the first focusable element, usually the close button. Pressing Shift + Tab will move to the last focusable item in the modal, usually the last button.

When Tab is pressed on the last focusable item, focus will shift to the first focusable item. When Shift + Tab is pressed on the first focusable item, focus will shift to the last focusable item.

When hidden, the modal will return focus to the element that was previously focused on the page.

Coral.Dialog API

Constructor

JavaScript:

new Coral.Dialog() or document.createElement('coral-dialog')

HTML Tag:

<coral-dialog>

Extends

Sub-components

Static Properties

Coral.Dialog.backdrop {String}

Dialog backdrop types.

Properties:

Name Type Value Description
NONE String none No backdrop.
MODAL String modal A backdrop that hides the dialog when clicked.
STATIC String static A backdrop that does not hide the dialog when clicked.

Coral.Dialog.closable {String}

Boolean enumeration for dialog closable state.

Properties:

Name Type Value Description
ON String on Show a close button on the dialog and close the dialog when clicked.
OFF String off Do not show a close button. Elements with the coral-close attributes will stil close the dialog.

Coral.Dialog.interaction {String}

Boolean enumeration for dialog keyboard interaction state.

Properties:

Name Type Value Description
ON String on Keyboard interaction is enabled.
OFF String off Keyboard interaction is disabled.

Coral.Dialog.variant {String}

Dialog variants.

Properties:

Name Type Value Description
DEFAULT String default A dialog with the default, gray header and no icon.
ERROR String error A dialog with a red header and warning icon, indicating that an error has occurred.
WARNING String warning A dialog with an orange header and warning icon, notifying the user of something important.
SUCCESS String success A dialog with a green header and checkmark icon, indicates to the user that an operation was successful.
HELP String help A dialog with a blue header and question mark icon, provides the user with help.
INFO String info A dialog with a blue header and info icon, informs the user of non-critical information.

Instance Properties

instance.backdrop {Coral.Dialog.backdrop}

The backdrop configuration for this dialog.
Default Value:
  • Coral.Dialog.backdrop.MODAL
HTML Attribute:
  • backdrop

instance.closable {Coral.Dialog.closable}

Reflected
Whether the dialog should have a close button.
Default Value:
  • Coral.Dialog.closable.OFF
HTML Attribute:
  • closable

instance.content {HTMLElement}

The dialog's content element.

instance.focusOnShow {Coral.mixin.overlay.focusOnShow}

Whether to focus when opened.
Inherited From:
Default Value:
  • Coral.mixin.overlay.focusOnShow.OFF
HTML Attribute:
  • focusonshow

instance.footer {HTMLElement}

The dialog's footer element.

instance.fullscreen {Boolean}

Reflected
Whether the dialog should be displayed full screen (without borders or margin).
Default Value:
  • false
HTML Attribute:
  • fullscreen

instance.header {HTMLElement}

The dialog's header element.

instance.icon {String}

The dialog's icon.
Default Value:
  • ""
HTML Attribute:
  • icon

instance.interaction {Coral.Dialog.interaction}

Whether keyboard interaction is enabled.
Default Value:
  • Coral.Dialog.interaction.ON

instance.returnFocus {Coral.mixin.overlay.returnFocus}

Whether to return focus to the previously focused element when closed.
Default Value:
  • Coral.mixin.overlay.returnFocus.ON
HTML Attribute:
  • returnfocus

instance.trapFocus {Coral.mixin.overlay.trapFocus}

Whether to trap tabs and keep them within the overlay.
Default Value:
  • Coral.mixin.overlay.trapFocus.ON
HTML Attribute:
  • trapfocus

instance.variant {Coral.Dialog.variant}

The dialog's variant.
Default Value:
  • Coral.Dialog.variant.DEFAULT
HTML Attribute:
  • variant

Methods

instance.center

Centers the dialog in the middle of the screen.
Returns:
this, chainable. {Coral.Dialog}

instance.get

Get the value of a property.
Parameters:
Name Type Description
property String The name of the property to fetch the value of.
Returns:
Property value. {*}
Inherited From:

instance.hide

Close the overlay.
Returns:
this, chainable {Coral.Component}
Inherited From:

instance.off

Remove an event listener.
Parameters:
Name Type Optional Description
eventName String No
The event name to stop listening for.
selector String Yes
The selector that was used for event delegation.
func function No
The function that was passed to on().
useCapture Boolean Yes
Only remove listeners with useCapture set to the value passed in.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.on

Add an event listener.
Parameters:
Name Type Optional Default Description
eventName String No
The event name to listen for.
selector String Yes
The selector to use for event delegation.
func function No
The function that will be called when the event is triggered.
useCapture Boolean Yes
false Whether or not to listen during the capturing or bubbling phase.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.remove

Non-destructively remove this element. It can be re-added by simply appending it to the document again. It will be garbage collected if there are no more references to it. This is different from using jQuery's remove(), which is destructive in that it removes data and listeners.
Inherited From:

instance.returnFocusTo

Set the element that focus should be returned to when the overlay is hidden.
Parameters:
Name Type Description
element HTMLElement The element to return focus to. This must be a DOM element, not a jQuery object or selector.
Returns:
this, chainable {Coral.Component}
Inherited From:

instance.show

Open the overlay and set the z-index accordingly.
Returns:
this, chainable {Coral.Component}
Inherited From:

instance.trigger

Trigger an event.
Parameters:
Name Type Optional Default Description
eventName String No
The event name to trigger.
props Object Yes
Additional properties to make available to handlers as event.detail.
bubbles Boolean Yes
true Set to false to prevent the event from bubbling.
cancelable Boolean Yes
true Set to false to prevent the event from being cancelable.
Returns:
CustomEvent object {CustomEvent}
Inherited From:

Events

coral-component:attached

Triggered when the component is attached to the DOM.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

coral-component:detached

Triggered when the component is detached to the DOM.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

coral-component:ready

Triggerred when the component has been upgraded and is ready for use.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

coral-overlay:beforeclose

Triggerred before the component is closed with hide() or instance.open = false.
Callback Parameters:
Name Type Description
event Object

Event object.

Name Type Description
event.preventDefault function Call to stop the overlay from closing.
Inherited From:

coral-overlay:beforeopen

Triggerred before the component is opened with show() or instance.open = true.
Callback Parameters:
Name Type Description
event Object

Event object.

Name Type Description
event.preventDefault function Call to stop the overlay from opening.
Inherited From:

coral-overlay:close

Triggerred after the component is closed with hide() or instance.open = false
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

coral-overlay:open

Triggerred after the overlay is opened with show() or instance.open = true
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

Coral.Dialog.Content API

Constructor

JavaScript:

new Coral.Dialog.Content() or document.createElement('coral-dialog-content')

HTML Tag:

<coral-dialog-content>

Extends

Methods

instance.get

Get the value of a property.
Parameters:
Name Type Description
property String The name of the property to fetch the value of.
Returns:
Property value. {*}
Inherited From:

instance.hide

Hide this component.
Returns:
this, chainable {Coral.Component}
Inherited From:

instance.off

Remove an event listener.
Parameters:
Name Type Optional Description
eventName String No
The event name to stop listening for.
selector String Yes
The selector that was used for event delegation.
func function No
The function that was passed to on().
useCapture Boolean Yes
Only remove listeners with useCapture set to the value passed in.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.on

Add an event listener.
Parameters:
Name Type Optional Default Description
eventName String No
The event name to listen for.
selector String Yes
The selector to use for event delegation.
func function No
The function that will be called when the event is triggered.
useCapture Boolean Yes
false Whether or not to listen during the capturing or bubbling phase.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.remove

Non-destructively remove this element. It can be re-added by simply appending it to the document again. It will be garbage collected if there are no more references to it. This is different from using jQuery's remove(), which is destructive in that it removes data and listeners.
Inherited From:

instance.show

Show this component.
Returns:
this, chainable {Coral.Component}
Inherited From:

instance.trigger

Trigger an event.
Parameters:
Name Type Optional Default Description
eventName String No
The event name to trigger.
props Object Yes
Additional properties to make available to handlers as event.detail.
bubbles Boolean Yes
true Set to false to prevent the event from bubbling.
cancelable Boolean Yes
true Set to false to prevent the event from being cancelable.
Returns:
CustomEvent object {CustomEvent}
Inherited From:

Events

coral-component:attached

Triggered when the component is attached to the DOM.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

coral-component:detached

Triggered when the component is detached to the DOM.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

coral-component:ready

Triggerred when the component has been upgraded and is ready for use.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

Coral.Dialog.Footer API

Constructor

JavaScript:

new Coral.Dialog.Footer() or document.createElement('coral-dialog-footer')

HTML Tag:

<coral-dialog-footer>

Extends

Methods

instance.get

Get the value of a property.
Parameters:
Name Type Description
property String The name of the property to fetch the value of.
Returns:
Property value. {*}
Inherited From:

instance.hide

Hide this component.
Returns:
this, chainable {Coral.Component}
Inherited From:

instance.off

Remove an event listener.
Parameters:
Name Type Optional Description
eventName String No
The event name to stop listening for.
selector String Yes
The selector that was used for event delegation.
func function No
The function that was passed to on().
useCapture Boolean Yes
Only remove listeners with useCapture set to the value passed in.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.on

Add an event listener.
Parameters:
Name Type Optional Default Description
eventName String No
The event name to listen for.
selector String Yes
The selector to use for event delegation.
func function No
The function that will be called when the event is triggered.
useCapture Boolean Yes
false Whether or not to listen during the capturing or bubbling phase.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.remove

Non-destructively remove this element. It can be re-added by simply appending it to the document again. It will be garbage collected if there are no more references to it. This is different from using jQuery's remove(), which is destructive in that it removes data and listeners.
Inherited From:

instance.show

Show this component.
Returns:
this, chainable {Coral.Component}
Inherited From:

instance.trigger

Trigger an event.
Parameters:
Name Type Optional Default Description
eventName String No
The event name to trigger.
props Object Yes
Additional properties to make available to handlers as event.detail.
bubbles Boolean Yes
true Set to false to prevent the event from bubbling.
cancelable Boolean Yes
true Set to false to prevent the event from being cancelable.
Returns:
CustomEvent object {CustomEvent}
Inherited From:

Events

coral-component:attached

Triggered when the component is attached to the DOM.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

coral-component:detached

Triggered when the component is detached to the DOM.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

coral-component:ready

Triggerred when the component has been upgraded and is ready for use.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

Coral.Dialog.Header API

Constructor

JavaScript:

new Coral.Dialog.Header() or document.createElement('coral-dialog-header')

HTML Tag:

<coral-dialog-header>

Extends

Methods

instance.get

Get the value of a property.
Parameters:
Name Type Description
property String The name of the property to fetch the value of.
Returns:
Property value. {*}
Inherited From:

instance.hide

Hide this component.
Returns:
this, chainable {Coral.Component}
Inherited From:

instance.off

Remove an event listener.
Parameters:
Name Type Optional Description
eventName String No
The event name to stop listening for.
selector String Yes
The selector that was used for event delegation.
func function No
The function that was passed to on().
useCapture Boolean Yes
Only remove listeners with useCapture set to the value passed in.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.on

Add an event listener.
Parameters:
Name Type Optional Default Description
eventName String No
The event name to listen for.
selector String Yes
The selector to use for event delegation.
func function No
The function that will be called when the event is triggered.
useCapture Boolean Yes
false Whether or not to listen during the capturing or bubbling phase.
Returns:
this, chainable. {Coral.Component}
Inherited From:

instance.remove

Non-destructively remove this element. It can be re-added by simply appending it to the document again. It will be garbage collected if there are no more references to it. This is different from using jQuery's remove(), which is destructive in that it removes data and listeners.
Inherited From:

instance.show

Show this component.
Returns:
this, chainable {Coral.Component}
Inherited From:

instance.trigger

Trigger an event.
Parameters:
Name Type Optional Default Description
eventName String No
The event name to trigger.
props Object Yes
Additional properties to make available to handlers as event.detail.
bubbles Boolean Yes
true Set to false to prevent the event from bubbling.
cancelable Boolean Yes
true Set to false to prevent the event from being cancelable.
Returns:
CustomEvent object {CustomEvent}
Inherited From:

Events

coral-component:attached

Triggered when the component is attached to the DOM.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

coral-component:detached

Triggered when the component is detached to the DOM.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From:

coral-component:ready

Triggerred when the component has been upgraded and is ready for use.
Callback Parameters:
Name Type Description
event Object Event object.
Inherited From: