Modal

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

Design system docs Examples Default Modal
Open Modal

Modal content

Customized Modal
Open Modal Like a tray?

Opened like a tray

I like tray I don't ike tray
Events

Modal has many events according to its state. You can listen to these events to trigger some actions. Most important event is the dds-close event, which is triggered when the modal is closed. The events detail properry contains the source of the event. This can be ok-button, cancel-button, close-button, overlay, or esc.

Issues

There is a know issue in Safari when using React. When the modal is opened, safari does not recognize the content in the modal content slot, and the content is not resized to the new height. This is a known Safari bug. I this case you can set the modal to a fixed size, or use the the followin css:

#modal::part(panel) {
  height: auto;
}
Importing Per-component import (Recommended)

Import the component by its own subpath. This registers <dap-ds-modal> (and the components it renders internally) and lets your bundler include only what you use:

import 'dap-design-system/components/modal'

Need a reference to the class (e.g. to register it manually or extend it)? The same subpath default-exports it:

import DapDSModal from 'dap-design-system/components/modal'
Register everything

Register the whole library at once — convenient, but pulls every component into your bundle:

import 'dap-design-system'
Importing React
import { DapDSModalReact } from 'dap-design-system/react'
Attributes
PropertyTypeDefaultDescription
bottomFooterbooleantruePushes the footer to the bottom.
openbooleanfalseThe open state of the modal.
openedbooleanfalseDeprecated: use open instead.
titlestringTitle of the modal.
descriptionstringDescription of the modal.
fullScreenbooleanfalseFull screen version of the modal.
noModalbooleanfalseIf true, uses .show() (no overlay); if false, uses .showModal(). Default is false.
size'sm', 'lg''sm'Size of the modal. Default is 'sm'.
sizeMapstring''Breakpoint→size map for the modal (e.g. "md:lg").
headerstring, boolean'true'Whether to show the header. Default is 'true'.
footerstring, boolean'true'Whether to show the footer. Default is 'true'.
wideFooterbooleanfalseWide layout mode for footer.
fixedHeaderbooleanfalseFixes the header to the top.
fixedFooterbooleanfalseFixes the footer to the bottom.
closeOnEscstring, boolean'true'Whether to close on Escape key. Default is 'true'.
closeOnOverlayClickstring, boolean'true'Whether to close on overlay click. Default is 'true'.
closeButtonstring, boolean'true'Whether to show the close button. Default is 'true'.
okButtonLabelstringLabel of the OK button.
okButtonDisabledbooleanfalseWhether the OK button is disabled.
okButtonDangerbooleanfalseWhether the OK button uses danger style.
hideOkButtonbooleanfalseWhether to hide the OK button.
okButtonSizestring''Override size for the OK button; empty uses modal size.
okButtonSizeMapstring''Override sizeMap for the OK button.
cancelButtonLabelstringLabel of the Cancel button.
cancelButtonDisabledbooleanfalseWhether the Cancel button is disabled.
cancelButtonDangerbooleanfalseWhether the Cancel button uses danger style.
hideCancelButtonbooleanfalseWhether to hide the Cancel button.
cancelButtonSizestring''Override size for the Cancel button; empty uses modal size.
cancelButtonSizeMapstring''Override sizeMap for the Cancel button.
closeButtonSizestring'md'Override size for the close icon button; empty uses modal size.
closeButtonSizeMapstring''Override sizeMap for the close icon button.
useNativeFocusbooleanfalseUse native browser focus handling. Default is false.
describeContentbooleanfalseAlso links the body to the dialog as its description (aria-describedby), so a screen reader reads it out on open. Best for short, text-only content. Default is false.
parentSizedstring, boolean'false'
spacingElementSpacing'none'
closeButtonLabelstring
okButtonVariantButtonVariant'primary'
cancelButtonVariantButtonVariant'outline'
okButtonTestIdstring'modal-ok-button'data-testid for the default OK button.
cancelButtonTestIdstring'modal-cancel-button'data-testid for the default Cancel button.
closeButtonTestIdstring'modal-close-button'data-testid for the default close icon button.
ariaLabelstring, nullnullAccessible label for the element. Use this to provide a text alternative
for elements that don't have visible text content.
ariaExpanded'true', 'false'nullIndicates whether the element is expanded or collapsed.
ariaControlsstring, nullnullIdentifies the element that is controlled by this element.
ariaHasPopupstring, nullnullIndicates the availability and type of interactive popup element.
ariaDescribedBystring, nullnullIdentifies the element that describes the current element.
ariaPressed'true', 'false' , 'mixed'nullIndicates the current "pressed" state of toggle buttons.
ariaHidden'true', 'false'nullIndicates whether the element is hidden from accessibility APIs.
customStylesstring, undefinedCustom CSS text to be merged with the component's styles.
This CSS will be injected into the shadow DOM and merged with the component's static styles.
Slots
NameDescription
(default)The content of the modal.
titleThe title of the modal.
descriptionThe description of the modal.
footerThe footer of the modal.
Events
Event NameDescriptionType
dds-before-openFires before the modal opens.{void }
dds-openedFires after the modal opens.{void }
dds-before-closeFires before the modal closes.{void }
dds-closedFires after the modal closed.{void }
dds-closeFires when the modal is closes. You can prevent the modal from closing by calling `event.preventDefault()`.{void }
dds-okFires when the OK button is clicked. You can prevent the modal from closing by calling `event.preventDefault()`.{void }
dds-cancelFires when the Cancel button is clicked. You can prevent the modal from closing by calling `event.preventDefault()`.{void }
CSS Parts
Part NameDescription
baseThe main modal container.
panelThe panel of the modal.
headerThe header of the modal.
header-containerThe container of the header.
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.
How to Use CSS Parts

You can style CSS parts using the ::part() pseudo-element selector:

/* Target a specific part */
.my-custom-dap-ds-modal::part(base) {
  /* Your custom styles */
}

/* Target multiple parts */
.my-custom-dap-ds-modal::part(base),
.my-custom-dap-ds-modal::part(panel) {
  /* Shared styles */
}

Example usage:

<dap-ds-modal class="my-custom-dap-ds-modal">
  Modal
</dap-ds-modal>
.my-custom-dap-ds-modal::part(base) {
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

CSS parts allow you to style internal elements of the component while maintaining encapsulation. Learn more in our styling guide.

CSS Custom Properties
Property NameDescription
--dds-modal-max-block-sizeMaximum height of the modal. (default: 80vh).
--dds-modal-max-inline-sizeMaximum width of the modal. (default: 600px).
--dds-modal-padding-smPadding inside the modal. (default: var(--dds-spacing-600)).
--dds-modal-padding-lgPadding inside the modal. (default: var(--dds-spacing-1200)).
--dds-modal-transform-amountAmount to transform for entrance animation. (default: 2rem).
--dds-modal-transition-speedSpeed of transition animations. (default: var(--dds-transition-fast)).
--dds-modal-transition-timingTiming function for transitions. (default: var(--dds-easing-ease-in-out)).
--dds-modal-border-widthBorder width of the modal. (default: var(--dds-border-width-base)).
--dds-modal-border-colorBorder color of the modal. (default: var(--dds-border-neutral-divider)).
--dds-modal-border-radiusBorder radius of the modal. (default: var(--dds-radius-large, 16px)).
--dds-modal-backgroundBackground color of the modal. (default: var(--dds-background-neutral-subtle)).
--dds-modal-header-margin-smMargin below the header. (default: var(--dds-spacing-400)).
--dds-modal-header-margin-lgMargin below the header. (default: var(--dds-spacing-600)).
--dds-modal-footer-margin-smMargin above the footer. (default: var(--dds-spacing-400)).
--dds-modal-footer-margin-lgMargin above the footer. (default: var(--dds-spacing-600)).
--dds-modal-footer-gapGap between footer elements. (default: var(--dds-spacing-200)).
--dds-modal-close-marginMargin for the close button. (default: var(--dds-spacing-300)).
How to Use CSS Custom Properties

CSS custom properties (CSS variables) can be set directly on the component or in your stylesheet:

Method 1: Inline styles (Quick customization)

<dap-ds-modal
  style="--dds-modal-max-block-size: value; --dds-modal-max-inline-size: value;">
  Modal
</dap-ds-modal>

Method 2: CSS classes (Reusable styles)

.my-custom-dap-ds-modal {
  --dds-modal-max-block-size: value;
  --dds-modal-max-inline-size: value;
  --dds-modal-padding-sm: value;
}
<dap-ds-modal class="my-custom-dap-ds-modal">
  Modal
</dap-ds-modal>

Method 3: Global theme customization

/* Apply to all instances */
dap-ds-modal {
  --dds-modal-max-block-size: value;
  --dds-modal-max-inline-size: value;
}

CSS custom properties inherit through the Shadow DOM, making them perfect for theming. Changes apply immediately without rebuilding.