Tray

Tray component is a popup component which can slide in from any side of the screen. It can be used to display additional information or actions.

Design system docs Examples Default tray

The dap-ds-tray component is basically a dap-ds-modal component with some specific styling, so all the attributes and events of the dap-ds-modal component are available for the dap-ds-tray component as well. Default tray is using the open attribute to open or close the tray. Default placement is bottom.

Open tray

Tray content

Placement

You can set the placement attribute to top, right, bottom or left to change the direction of the tray.

Open bottom

Tray content

Open left

Tray content

Open right

Tray content

Open top

Tray content

Importing Per-component import (Recommended)

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

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

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

import DapDSTray from 'dap-design-system/components/tray'
Register everything

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

import 'dap-design-system'
Importing React
import { DapDSTrayReact } from 'dap-design-system/react'
Attributes
PropertyTypeDefaultDescription
placement'left', 'right' , 'top' , 'bottom''bottom'The placement of the tray.
footerstring, boolean'false'Whether the tray should have a footer. Default is false.
headerstring, boolean'false'Whether the tray should have a header. Default is false.
openbooleanfalseThe open state of the tray.
openedbooleanfalseDeprecated: use open instead.
noModalbooleanfalseWhether the tray should have a modal overlay. Default is false. If true the tray will use the .show() method, if false the tray will use the .showModal() method.
closeOnEscstring, boolean'true'Whether the tray should close on pressing the escape key. Default is true.
closeOnOverlayClickstring, boolean'true'Whether the tray should close on clicking the overlay. Default is true.
closeButtonstring, boolean'true'Whether the tray should have a close button. Default is true.
titlestringThe title of the tray.
descriptionstringThe description of the tray.
okButtonLabelstringThe label of the OK button.
cancelButtonLabelstringThe label of the Cancel button.
size'sm', 'lg''sm'The size of the tray. Default is 'sm'.
describeContentbooleanfalseAlso links the body to the tray as its description (aria-describedby), so a screen reader reads it out on open. Best for short, text-only content. Default is false.
sizeMapstring''Breakpoint→size map; e.g. "md:lg" applies at md and all narrower breakpoints. Keys: xs, sm, md, lg, xl, 2xl.
parentSizedstring, boolean'false'
spacingElementSpacing'none'
fullScreenboolean, undefinedfalse
closeButtonLabelstring
okButtonVariantButtonVariant'primary'
cancelButtonVariantButtonVariant'outline'
okButtonDisabledbooleanfalse
cancelButtonDisabledbooleanfalse
cancelButtonDangerbooleanfalse
okButtonDangerbooleanfalse
hideOkButtonbooleanfalse
hideCancelButtonbooleanfalse
okButtonSizestring''Override size for the default OK button; when empty uses the modal's effective size.
okButtonSizeMapstring''Override sizeMap for the default OK button; when empty uses the modal's sizeMap.
cancelButtonSizestring''Override size for the default Cancel button; when empty uses the modal's effective size.
cancelButtonSizeMapstring''Override sizeMap for the default Cancel button; when empty uses the modal's sizeMap.
closeButtonSizestring'md'Override size for the close icon button; when empty uses the modal's effective size.
closeButtonSizeMapstring''Override sizeMap for the close icon button; when empty uses the modal's sizeMap.
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.
wideFooterbooleanfalse
bottomFooterbooleanfalse
useNativeFocusbooleanfalse
fixedHeaderbooleanfalse
fixedFooterbooleanfalse
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 tray.
headerThe header of the tray.
footerThe footer of the tray.
Events
Event NameDescriptionType
dds-before-openFires before the tray opens.{void }
dds-openedFires after the tray opens.{void }
dds-before-closeFires before the tray closes.{void }
dds-closedFires after the tray closed.{void }
dds-closeFires when the tray is closes. You can prevent the tray from closing by calling `event.preventDefault()`.{void }
CSS Parts
Part NameDescription
baseThe main tray container.
panelThe panel of the tray.
headerThe header of the tray.
footerThe footer of the tray.
contentThe content of the tray.
header-containerThe container of the header.
titleThe title of the tray.
descriptionThe description of the tray.
closebuttonThe close button of the tray.
How to Use CSS Parts

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

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

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

Example usage:

<dap-ds-tray class="my-custom-dap-ds-tray">
  Tray
</dap-ds-tray>
.my-custom-dap-ds-tray::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-400))
--dds-modal-close-marginMargin for the close button. (default: var(--dds-spacing-300))
--dds-tray-width-sideWidth of the side (left/right) trays. (default: 250px)
--dds-tray-min-width-horizontalMinimum width of the horizontal (top/bottom) trays. (default: 400px)
--dds-tray-min-height-horizontalMinimum height of the horizontal (top/bottom) trays. (default: 300px)
--dds-tray-min-height-verticalMinimum height of the vertical (left/right) trays. (default: 100%)
--dds-tray-transform-durationDuration of the transform animation. (default: 0.3s)
--dds-tray-transform-timingTiming function for the transform animation. (default: ease-in-out)
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-tray
  style="--dds-modal-max-block-size: value; --dds-modal-max-inline-size: value;">
  Tray
</dap-ds-tray>

Method 2: CSS classes (Reusable styles)

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

Method 3: Global theme customization

/* Apply to all instances */
dap-ds-tray {
  --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.