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/dist/dds'
Importing React
import { DapDSTrayReact } from 'dap-design-system/dist/react'
Slots
NameDescription
(default)The content of the tray.
headerThe header of the tray.
footerThe footer of the tray.
Attributes
PropertyTypeDefaultDescription
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.
footerstringWhether the tray should have a footer. Default is false.
headerstringWhether the tray should have a header. Default is false.
placement'left' 'right' 'top' 'bottom''bottom'The placement of the tray. Default is bottom. Can be left, right, top, or bottom.
Events
Event NameDescription
dds-before-openFires before the tray opens.
dds-openedFires after the tray opens.
dds-before-closeFires before the tray closes.
dds-closedFires after the tray closed.
dds-closeFires when the tray is closes. You can prevent the tray from closing by calling `event.preventDefault()`.
CSS Parts
Part NameDescription
baseThe main tray container.
panelThe panel of the tray.
headerThe header of the tray.
footerThe footer of the tray.
bodyThe body of the tray.