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.

<div>
<dap-ds-button id="open-tray" onClick={() => 
  document.querySelector('dap-ds-tray').open = true
}>
  Open tray
</dap-ds-button>

<dap-ds-tray>
  <p>Tray content</p>
</dap-ds-tray>

</div>
Placement

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

<dap-ds-stack direction="row">
<dap-ds-button id="open-tray" onClick={() => 
  document.querySelector('#bottom').open = true
}>
  Open bottom
</dap-ds-button>

<dap-ds-tray id="bottom" placement="bottom">
  <p>Tray content</p>
</dap-ds-tray>

<dap-ds-button id="open-tray" onClick={() => 
  document.querySelector('#left').open = true
}>
  Open left
</dap-ds-button>

<dap-ds-tray id="left"  placement="left">
  <p>Tray content</p>
</dap-ds-tray>

<dap-ds-button id="open-tray" onClick={() => 
  document.querySelector('#right').open = true
}>
  Open right
</dap-ds-button>

<dap-ds-tray id="right" placement="right">
  <p>Tray content</p>
</dap-ds-tray>

<dap-ds-button id="open-tray" onClick={() => 
  document.querySelector('#top').open = true
}>
  Open top
</dap-ds-button>

<dap-ds-tray id="top"  placement="top">
  <p>Tray content</p>
</dap-ds-tray>
</dap-ds-stack>
Importing
import { DapDSTray } from 'dap-design-system'
Importing React
import { DapDSTrayReact } from 'dap-design-system/react'
Tree-Shakeable Imports

For optimal bundle sizes, use the tree-shakeable import syntax:

import { DapDSTray } from 'dap-design-system/components'
Attributes
PropertyTypeDefaultDescription
placement'left', 'right' , 'top' , 'bottom''bottom'The placement of the tray.
footerstring'false'Whether the tray should have a footer. Default is false.
headerstring'false'Whether the tray should have a header. Default is false.
openbooleanThe open state of the tray.
closeOnEscbooleanWhether the tray should close on pressing the escape key. Default is true.
closeOnOverlayClickbooleanWhether the tray should close on clicking the overlay. Default is true.
closeButtonstringWhether 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'The size of the tray. Default is 'sm'.
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.
bodyThe body 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.