Modal

Modal is a dialog box or popup window that is displayed on top of the current page.

Design system docs

Examples Default Modal
<>
    <dap-ds-button onclick="document.querySelector('#basicmodal').open = true">Open Modal</dap-ds-button>
    <dap-ds-modal id="basicmodal" title="Modal title" description="Description">
      <p>Modal content</p>
    </dap-ds-modal>
  </>
Customized Modal
<>
    <dap-ds-button onclick="document.getElementById('tray-bottom').open = true">Open Modal</dap-ds-button>
    <dap-ds-modal id="tray-bottom">
      <dap-ds-typography variant="h1" slot="title"
        >Like a tray?</dap-ds-typography
      >
      <p>Opened like a tray</p>
      <dap-ds-button slot="footer" onclick="document.getElementById('tray-bottom').open = false">I like tray</dap-ds-button>
      <dap-ds-button danger slot="footer" onclick="document.getElementById('tray-bottom').open = false">I don't ike tray</dap-ds-button>
    </dap-ds-modal>
  </>
Importing
import { DapDSModal } from 'dap-design-system/dist/dds'
Importing React
import { DapDSModalReact } from 'dap-design-system/dist/react'
Slots
NameDescription
(default)The content of the modal.
titleThe title of the modal.
descriptionThe description of the modal.
footerThe footer of the modal.
Attributes
PropertyTypeDefaultDescription
openbooleanThe open state of the modal.
closeOnEscbooleanWhether the modal should close on pressing the escape key. Default is true.
closeOnOverlayClickbooleanWhether the modal should close on clicking the overlay. Default is true.
closeButtonstringWhether the modal should have a close button. Default is true.
titlestringThe title of the modal.
descriptionstringThe description of the modal.
okButtonLabelstringThe label of the OK button.
cancelButtonLabelstringThe label of the Cancel button.
footerstringWhether the modal should have a footer. Default is true.
headerstringWhether the modal should have a header. Default is true.
Events
Event NameDescription
dds-before-openFires before the modal opens.
dds-openedFires after the modal opens.
dds-before-closeFires before the modal closes.
dds-closedFires after the modal closed.
dds-closeFires when the modal is closes. You can prevent the modal from closing by calling `event.preventDefault()`.
CSS Parts
Part NameDescription
baseThe main modal container.
panelThe panel of the modal.
headerThe header of the modal.
titleThe title of the modal.
descriptionThe description of the modal.
footerThe footer of the modal.
contentThe body of the modal.
closebuttonThe close button of the modal.