Modal Dialog

Use modal dialogs to show force a selection between two options. View this component on GitHub

Contents

Basic

This example shows a basic Modal Dialog.

Show Modal Dialog
If you leave this page, your survey won't be saved and can't be recovered
Leave pageContinue survey
<admiralty-modal-dialog
  heading="Do you want to leave this page?"
  show="true"
  label="Do you want to leave this page?"
  description="If you leave this page, your survey won't be saved and can't be recovered"
>
  <div slot="content">
    <admiralty-icon name="warning-rounded"></admiralty-icon>
    <div>If you leave this page, your survey won't be saved and can't be recovered</div>
  </div>
  <div slot="actions">
    <admiralty-button variant="secondary">Leave page</admiralty-button>
    <admiralty-button>Continue survey</admiralty-button>
  </div>
</admiralty-modal-dialog>
<admiralty-modal-dialog
  heading="Do you want to leave this page?"
  show="true"
  label="Do you want to leave this page?"
  description="If you leave this page, your survey won't be saved and can't be recovered"
>
  <div slot="content">
    <admiralty-icon name="warning-rounded"></admiralty-icon>
    <div>If you leave this page, your survey won't be saved and can't be recovered</div>
  </div>
  <div slot="actions">
    <admiralty-button variant="secondary">Leave page</admiralty-button>
    <admiralty-button>Continue survey</admiralty-button>
  </div>
</admiralty-modal-dialog>
<AdmiraltyModalDialog
  heading="Do you want to leave this page?"
  show={true}
  label="Do you want to leave this page?"
  description="If you leave this page, your survey won't be saved and can't be recovered">
  <div slot="content">
    <AdmiraltyIcon name="warning-rounded"></AdmiraltyIcon>
    <div>If you leave this page, your survey won't be saved and can't be recovered</div>
  </div>
  <div slot="actions">
    <AdmiraltyButton variant="secondary">Leave page</AdmiraltyButton>
    <AdmiraltyButton>Continue survey</AdmiraltyButton>
  </div>
</AdmiraltyModalDialog>

Accessibility

Use the label and description props to provide better accessibility for the modal dialog.

Content Design

When using the modal dialogue, you must: make it clear why you are displaying the modal dialogue using plain language not assume why the modal dialogue has been triggered. For example, using language like ‘Are you sure you want to leave this page?’ when the action to exit could have been accidental help users to understand what will happen next based on their next action.

Have clear and concise content and do not use: jargon like 500 or bad request ‘We are experiencing technical difficulties’ red text to warn people.

Props

NameTypeDefaultDescriptiondescriptionstringundefinedDescribe the contents of the dialog.headingstringundefinedThe title of the modal dialog.labelstringundefinedLabel the dialog.showbooleanfalseWhether to show the modal dialog.

Events

No events available for this component.

Methods

No public methods available for this component.

CSS Shadow Parts

No CSS shadow parts available for this component.

CSS Custom Properties

NameDescription--admiralty-modal-dialog-content-paddingPadding for the modal dialog content--admiralty-modal-dialog-content-slotted-button-paddingPadding for the modal dialog content button slot--admiralty-modal-dialog-content-slotted-margin-bottomMargin bottom for the modal dialog content slot--admiralty-modal-dialog-content-slotted-paddingPadding for the modal dialog content slot--admiralty-modal-dialog-heading-margin-bottomMargin bottom for the modal dialog heading--admiralty-modal-dialog-heading-paddingPadding for the modal dialog heading--admiralty-modal-dialog-marginMargin for the modal dialog.--admiralty-modal-heading-font-sizeFont size for the modal dialog heading--admiralty-modal-heading-font-weightFont weight for the modal dialog heading--admiralty-modal-slotted-icon-font-sizeFont size for the modal dialog slotted icon--admiralty-modal-slotted-text-font-sizeFont size for the modal dialog slotted text

Slots

NameDescriptionactionsActions for the dialog.contentContent of the dialog.
Privacy PolicyAccessibility