Modal is a dialog box or popup window that is displayed on top of the current page.
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.
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;
}
import { DapDSModal } from 'dap-design-system'
import { DapDSModalReact } from 'dap-design-system/react'
For optimal bundle sizes, use the tree-shakeable import syntax:
import { DapDSModal } from 'dap-design-system/components'
| Property | Type | Default | Description |
|---|---|---|---|
bottomFooter | boolean | true | Pushes the footer to the bottom. |
open | boolean | The open state of the modal. | |
title | string | Title of the modal. | |
description | string | Description of the modal. | |
fullScreen | boolean | Full screen version of the modal. | |
noModal | boolean | If true, uses .show() (no overlay); if false, uses .showModal(). Default is false. | |
size | 'sm', 'lg' | Size of the modal. Default is 'sm'. | |
sizeMap | string | Breakpoint→size map for the modal (e.g. "md:lg"). | |
header | string | Whether to show the header. Default is 'true'. | |
footer | string | Whether to show the footer. Default is 'true'. | |
wideFooter | boolean | Wide layout mode for footer. | |
fixedHeader | boolean | Fixes the header to the top. | |
fixedFooter | boolean | Fixes the footer to the bottom. | |
closeOnEsc | string | Whether to close on Escape key. Default is 'true'. | |
closeOnOverlayClick | string | Whether to close on overlay click. Default is 'true'. | |
closeButton | string | Whether to show the close button. Default is 'true'. | |
okButtonLabel | string | Label of the OK button. | |
okButtonDisabled | boolean | Whether the OK button is disabled. | |
okButtonDanger | boolean | Whether the OK button uses danger style. | |
hideOkButton | boolean | Whether to hide the OK button. | |
okButtonSize | string | Override size for the OK button; empty uses modal size. | |
okButtonSizeMap | string | Override sizeMap for the OK button. | |
cancelButtonLabel | string | Label of the Cancel button. | |
cancelButtonDisabled | boolean | Whether the Cancel button is disabled. | |
cancelButtonDanger | boolean | Whether the Cancel button uses danger style. | |
hideCancelButton | boolean | Whether to hide the Cancel button. | |
cancelButtonSize | string | Override size for the Cancel button; empty uses modal size. | |
cancelButtonSizeMap | string | Override sizeMap for the Cancel button. | |
closeButtonSize | string | Override size for the close icon button; empty uses modal size. | |
closeButtonSizeMap | string | Override sizeMap for the close icon button. | |
useNativeFocus | boolean | Use native browser focus handling. Default is false. |
| Name | Description |
|---|---|
(default) | The content of the modal. |
title | The title of the modal. |
description | The description of the modal. |
footer | The footer of the modal. |
| Event Name | Description | Type |
|---|---|---|
dds-before-open | Fires before the modal opens. | {void } |
dds-opened | Fires after the modal opens. | {void } |
dds-before-close | Fires before the modal closes. | {void } |
dds-closed | Fires after the modal closed. | {void } |
dds-close | Fires when the modal is closes. You can prevent the modal from closing by calling `event.preventDefault()`. | {void } |
dds-ok | Fires when the OK button is clicked. You can prevent the modal from closing by calling `event.preventDefault()`. | {void } |
dds-cancel | Fires when the Cancel button is clicked. You can prevent the modal from closing by calling `event.preventDefault()`. | {void } |
| Part Name | Description |
|---|---|
base | The main modal container. |
panel | The panel of the modal. |
header | The header of the modal. |
header-container | The container of the header. |
title | The title of the modal. |
description | The description of the modal. |
footer | The footer of the modal. |
content | The body of the modal. |
closebutton | The close button of the modal. |
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.
| Property Name | Description |
|---|---|
--dds-modal-max-block-size | Maximum height of the modal. (default: 80vh). |
--dds-modal-max-inline-size | Maximum width of the modal. (default: 600px). |
--dds-modal-padding-sm | Padding inside the modal. (default: var(--dds-spacing-600)). |
--dds-modal-padding-lg | Padding inside the modal. (default: var(--dds-spacing-1200)). |
--dds-modal-transform-amount | Amount to transform for entrance animation. (default: 2rem). |
--dds-modal-transition-speed | Speed of transition animations. (default: var(--dds-transition-fast)). |
--dds-modal-transition-timing | Timing function for transitions. (default: var(--dds-easing-ease-in-out)). |
--dds-modal-border-width | Border width of the modal. (default: var(--dds-border-width-base)). |
--dds-modal-border-color | Border color of the modal. (default: var(--dds-border-neutral-divider)). |
--dds-modal-border-radius | Border radius of the modal. (default: var(--dds-radius-large, 16px)). |
--dds-modal-background | Background color of the modal. (default: var(--dds-background-neutral-subtle)). |
--dds-modal-header-margin-sm | Margin below the header. (default: var(--dds-spacing-400)). |
--dds-modal-header-margin-lg | Margin below the header. (default: var(--dds-spacing-600)). |
--dds-modal-footer-margin-sm | Margin above the footer. (default: var(--dds-spacing-400)). |
--dds-modal-footer-margin-lg | Margin above the footer. (default: var(--dds-spacing-600)). |
--dds-modal-footer-gap | Gap between footer elements. (default: var(--dds-spacing-200)). |
--dds-modal-close-margin | Margin for the close button. (default: var(--dds-spacing-300)). |
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.