Vivid API

Dialog

Represents a part of an application that a user interacts with to perform a task.

Usage

Dialog uses the native dialog element.

import { registerDialog } from '@vonage/vivid-api';
registerDialog('your-prefix');

Use the modal attribute to set the dialog as Modal

  • Modal dialogs prevent users from interacting with the rest of the application until the dialog is closed and render a backdrop behind the dialog.
  • Non-modal dialogs allow users to interact with the rest of the application while the dialog is open.

Open

Sets or returns whether a dialog should be open or not.

Dismiss

When using this attribute, ensure that the dialog can be closed by other means.

No-light-dismiss

Use the no-light-dismiss attribute to prevent a modal dialog from being dismissed by clicking outside it.

No-Dismiss-On-Esc

Use the no-dismiss-on-esc attribute to prevent a modal dialog from being dismissed by pressing ESC.

No-Dismiss-Button

Use the no-dismiss-button attribute to remove the dismiss button from the dialog.

Non-Dismissible

The non-dismissible attribute combines no-light-dismiss, no-dismiss-on-esc, and no-dismiss-button.

Dismiss-Button-Aria-Label

The dismiss button is automatically given a localized version of the word “close”.
This can be overridden using dismiss-button-aria-label.

Return Value

Use returnValue to get or set the return value.
Often used to indicate which button the user pressed to close it.

Slots

Icon Slot

Use the icon slot to display an icon from the icon library. The icon slot is the preferred way to add an icon to the component.

Graphic Slot

Use the graphic slot in order to replace the icon.

The graphic slot overrides the icon property. Use the slot if a colored icon is needed or an icon with different dimensions.

Body Slot

Use the body slot in order to add custom HTML to the dialog.

When using body slot with a subtitle in the header, a separator will be added between the two.

Full-Width-Body

To remove the body inline padding use full-width-body.
Use full-width-body if Progress-Bar or Tabs are needed in the Dialog.

Action Items Slot

Use the action-items slot to add action items to the bottom of the dialog.

Use the footer slot in order to add additional content to the bottom of the dialog.

When used in combination with action-items slot, the footer content will appear to the left of the action items.

Main Slot

Dialog has predefined content style template. Use the main slot to fully override a Dialog’s predefined template with your own.

CSS Variables

Z-index

Use --dialog-z-index for a different z-index value than 1.

z-index will affect only id the Dialog is not modal.

Inline min & max size

The dialog has default --dialog-min-inline-size and --dialog-max-inline-size values, which can be changed if needed.

Setting the same value for --dialog-min-inline-size and --dialog-max-inline-size will set a definitive width to the dialog.

When setting a new value for —dialog-min-inline-size and —dialog-max-inline-size take in consideration if different values are needed for mobile.

Block-Size

The dialog has a default --dialog-max-block-size. If the content is larger, the dialog will be scrollable.

Inset

When the dialog is not used as a modal, you can overwrite default inset values using --dialog-inset-inline and --dialog-inset-block variables.

API Reference

Properties

PropertyTypeDefaultDescription
dismissButtonAriaLabelstring
fullWidthBodyboolean
headlinestring
iconPlacement'top' | 'side'
modalbooleanSets the element's to be opened
noDismissButtonbooleanRemove the element's dismiss button
noDismissOnEscbooleanprevent a modal dialog from being dismissed by pressing esc
noLightDismissbooleanprevent a modal dialog from being dismissed by clicking outside of it.
nonDismissiblebooleancombines `no-light-dismiss`, `no-dismiss-on-esc`, and `no-dismiss-button`
open
(open)
booleanSets the element's to be opened
returnValuestring
scrollableBodybooleanMakes only the element's content area between the header and footer scrollable
subtitlestring
PropertyTypeDefaultDescription
dismiss-button-aria-labelstring
full-width-bodyboolean
headlinestring
icon-placement'top' | 'side'
modalbooleanSets the element's to be opened
no-dismiss-buttonbooleanRemove the element's dismiss button
no-dismiss-on-escbooleanprevent a modal dialog from being dismissed by pressing esc
no-light-dismissbooleanprevent a modal dialog from being dismissed by clicking outside of it.
non-dismissiblebooleancombines `no-light-dismiss`, `no-dismiss-on-esc`, and `no-dismiss-button`
openbooleanSets the element's to be opened
returnValue
(property only)
string
scrollable-bodybooleanMakes only the element's content area between the header and footer scrollable
subtitlestring

Slots

NameDescription
action-itemsUse the action-items slot in order to add action buttons to the bottom of the dialog.
bodyUse the body slot in order to add custom HTML to the dialog.
footerUse the footer slot in order to add action buttons to the bottom of the dialog.
graphicUse the graphic slot in order to replace the icon.
iconThe preferred way to add an icon to the component.
mainAssign nodes to the main slot to fully override a dialog’s predefined flow and style with your own.
NameDescription
action-itemsUse the action-items slot in order to add action buttons to the bottom of the dialog.
bodyUse the body slot in order to add custom HTML to the dialog.
footerUse the footer slot in order to add action buttons to the bottom of the dialog.
graphicUse the graphic slot in order to replace the icon.
iconThe preferred way to add an icon to the component.
mainAssign nodes to the main slot to fully override a dialog’s predefined flow and style with your own.

Events

NameTypeDescription
cancelCustomEvent<undefined>The `cancel` event fires when the user requests to close the dialog. You can prevent the dialog from closing by calling `.preventDefault()` on the event.
closeCustomEvent<string>The `close` event fires when the dialog closes (either via user interaction or via the API). It returns the return value inside the event's details property.
openCustomEvent<undefined>The `open` event fires when the dialog opens.
NameTypeDescription
cancelCustomEvent<undefined>The `cancel` event fires when the user requests to close the dialog. You can prevent the dialog from closing by calling `.preventDefault()` on the event.
closeCustomEvent<string>The `close` event fires when the dialog closes (either via user interaction or via the API). It returns the return value inside the event's details property.
openCustomEvent<undefined>The `open` event fires when the dialog opens.

Methods

NameParamsReturnsDescription
closevoid
showvoid
showModalvoid