Skip to main content
Tray
@coinbase/cds-web@8.47.1
An elevated overlay container that slides in from any edge of the screen.
import { Tray } from '@coinbase/cds-web/overlays/tray/Tray'
Related components

Basics

The recommended way to use a Tray is to add to dom when visible, and use onCloseComplete to remove it. It is also recommended to pin it to the right side of the screen on tablet and desktop, and pin to bottom with handlebar on mobile.

Loading...

Pinning

While you can pin the tray to any side of the screen, it is recommended to only use pin to bottom or right. Bottom is recommended for mobile, and right is recommended for tablet and desktop.

Handlebar is only shown on bottom pinned trays, and adjusts the padding to match other pins. It is deprecated to use bottom pin without handlebar.

Loading...

Content

Web Tray will automatically be scrollable when the content is too large to fit. You can adjust verticalDrawerPercentageOfView to control the maximum height of the tray when pinned to the bottom or top.

When scrolling, a border is added to the header.

Loading...

With Illustration in Header

You can pass in a custom node to title to render a custom header.

Loading...

With Full Bleed Header

You can use a full bleed header with a background image. Use header and title to add a section header that stays fixed below the image while content scrolls. When scrolling, a border appears below the header area.

Loading...
With Scrollable List Cells

When using a full bleed header with scrollable content, the header prop keeps the section header fixed while list cells scroll beneath it.

Loading...

Controlled

You have various ways to control the state of a tray.

Via Ref

You can use a ref to control the tray, which provides a close() method.

Accessibility tip

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.

Loading...

Prevent Dismissal

You can prevent the user from dismissing the tray with preventDismiss. This will remove built in dismiss functionality, including swipe to close with handlebar, close button, pressing ESC, and clicking outside.

You must provide an explicit action button to close the tray.

Loading...

Accessibility

Accessibility labels

Trays require an accessibility label. If you pass in a ReactNode to title, make sure to set accessibilityLabel or accessibilityLabelledBy.

Reduce Motion

Use the reduceMotion prop to accommodate users with reduced motion settings.

Loading...

Styling

The Tray component exposes styles and classNames props for customizing various parts of the component. Available keys include: root, overlay, container, header, title, content, footer, handleBar, handleBarHandle, and closeButton.

Container

You can customize the tray's outer container to adjust the border radius for floating trays or change the max width.

Loading...

Title

For full bleed images, use the title prop with a Box containing an image.

Loading...

Content

You can customize the content area to adjust padding, background, or other properties.

Loading...

You can customize the footer section's appearance, such as the background color.

Loading...

Handlebar

You can customize the handlebar appearance to change its color and opacity. This is useful when the default handlebar color does not have enough contrast against an image header, such as inverting it to white for dark or colorful backgrounds.

Loading...

Close Button

You can customize the close button to adjust the button's appearance, such as to improve visibility against header images or custom backgrounds.

Loading...

Composed Examples

Floating

You can create a floating tray by adjusting the inset based on pin direction.

Loading...

Multiple Screen Example

You can create a tray with multiple screens that have back navigation.

Loading...

Header with Illustration

You can create a reusable responsive tray with a pictogram and title in the header.

Loading...

Responsive

You can create a reusable responsive tray that adapts its pin direction and handle bar visibility based on the viewport size.

Loading...

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.