Skip to main content

Dialog

A dialog is a pop-up dialog (rectangular panel) that takes focus, and prohibits the user from interacting with the content behind.

Use cases:

  • pop-up notification
  • configuration box

Example

The example below shows the component in action. Clicking on the Open Dialog button displays a dialog with some simple text. Click in the x in the top right corner to remove the dialog.

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. Default is center.
<rapid-dialog position="right">
show-close-iconbooleanEnables the close icon in the top right corner of the dialog. Default is true.
<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
showShows the dialog.dialogRef.show()
closeHides the dialog.dialogRef.close()

Slots

SlotDescription
DefaultAll the content that 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.