Skip to main content
Tray
@coinbase/cds-web@8.34.1
An elevated container pinned to the bottom of the screen.
Import
import { Tray } from '@coinbase/cds-web/overlays/tray/Tray'
SourceView source codeFigmaView Figma (internal only)
Related components
View as Markdown
Accessibility tip

Labels

Trays require an accessibility label, which we set to title by default. However, if you don't want to provide a title or there's other text that gives the user better context to the tray, then you can pass an element id to accessibilityLabelledBy. Alternatively, you may directly provide a contextual label to accessibilityLabel.

Basic usage with Callback

The recommended way to use a Tray is by passing a callback as children, which receives a handleClose function:

Loading...

Using Ref to Control the Tray

Accessibility tip

Trigger Focus

A ref to the trigger that opens the tray, along with an onClosedComplete method to reset focus on the trigger when the tray closes, needs to be wired up for accessibility (see code example below).

You can also control the Tray using a ref, which provides a close() method:

Loading...

Scrollable Content

Trays with long content will automatically be scrollable.

Loading...

Non-Dismissible Tray

Trays can be configured to prevent the user from dismissing the tray by clicking close, clicking outside, or pressing ESC.

Loading...

Multiple Overlay Flow

When transitioning between overlays, ensure proper dismounting using onCloseComplete:

Loading...

Note: The Tray component is an elevated container that is pinned to the bottom of the screen and provides a standardized way to present bottom sheets in your web application. Key points:

  • Use onCloseComplete for cleanup when the tray is dismissed
  • Children can be either a React node or a render function that receives a handleClose function
  • The ref provides open() and close() methods for controlling the tray
  • When transitioning between overlays, ensure proper dismounting using lifecycle methods

Is this page useful?

Coinbase Design is an open-source, adaptable system of guidelines, components, and tools that aid the best practices of user interface design for crypto products.