Skip to main content

Dialog

Dialogs are popup menus which take focus and prohibit the user interacting with the content behind.

Use cases:

  • Popup notification
  • Configuration box

Example

Open Dialog

Declaration

<rapid-dialog></rapid-dialog>

Usage

@customElement({
name: 'my-element',
template: html<MyElement>`
<rapid-dialog ${ref('dialog')}>
<h2>Dialog</h2>
<p>This is an example dialog.</p>
</rapid-dialog>
<rapid-button @click="${(x) => x.showDialog()}"></rapid-button>
`,
})
export class MyElement extends GenesisElement {
dialog: Dialog;
showDialog() {
this.dialog.show();
}
}

API

Attributes

AttributeTypeDescriptionExample
type'default' | 'error' | 'success'The general style of dialog type to show. default type adds no extra styling, error shows a red highlight and success shows a green.
<rapid-dialog type="success">
position'center' | 'left' | 'right'The position of the dialog. center is the default.
<rapid-dialog position="right">
show-close-iconbooleanEnables the close icon in the top right corner of the dialog. true is the default.
<rapid-dialog show-close-icon="false">

Properties

PropertyTypeDescriptionExample
onShowCallback() => voidFunction that runs before dialog is opened.
<rapid-dialog :onShowCallback="${(x) => () => x.beforeDialogShown()}">
onCloseCallback() => voidFunction that is called after the dialog is closed.
<rapid-dialog :onCloseCallback="${(x) => () => x.afterDialogHide()}">

Methods

MethodDescriptionExample
showShow the dialogdialogRef.show()
closeHides the dialogdialogRef.close()

Slots

SlotDescription
DefaultAll the content which you want to display on the dialog box when shown.
topCan be used to set a title section for the dialog.
bottomCan be used to set a footer section for the dialog.

Parts

PartDescription
dialogthe base html dialog tag
topThe top part of the dialog which contains the dialog header
bottomThe bottom part of the dialog which contains the dialog footer

Events fired

This component doesn't fire any events.

Events listened to

This component doesn't listen to any events.