Skip to main content
Toast
@coinbase/cds-web@8.38.5
A temporary notification that appears at the bottom of the screen.
import { Toast } from '@coinbase/cds-web/overlays/Toast'
Peer dependencies
  • framer-motion: ^10.18.0
Related components

Use the useToast hook to show toasts. Call toast.show() with a message to display a temporary notification.

Loading...

Actions

Add an action button to the toast for quick user actions like "Undo" or "View".

Loading...

Without Close Button

Hide the close button when you want a cleaner appearance or when the toast should only be dismissed via the action or timeout.

Loading...

Duration

Toast duration is automatically calculated based on content length:

  • Base duration: 5 seconds
  • With action: +2 seconds
  • Long text (>50 characters): +0.3s per 10 additional characters

You can override the automatic calculation by providing a custom duration in milliseconds.

Loading...

Positioning

Use bottomOffset to adjust the vertical position of the toast. This is useful when you have bottom navigation or other fixed elements.

Loading...

Styling

Variants

Use the variant prop to change the color surge effect on the toast background. This helps communicate the nature of the notification.

Loading...

Lifecycle Callbacks

Use onWillHide and onDidHide to respond to toast dismissal. This is useful for cleanup or triggering subsequent actions.

Loading...

Programmatic Control

Hiding Toasts

Use toast.hide() to programmatically dismiss the current toast.

Loading...

Clearing the Queue

When multiple toasts are triggered, they queue up. Use toast.clearQueue() to remove all pending toasts.

Loading...

Accessibility

Toast uses role="alert" for screen reader announcements. On web, the toast persists when the user hovers over it, giving them time to read the content.

For internationalization, you can customize the close button's accessibility label:

Loading...

Composed Examples

Form Submission Feedback

A common pattern is showing toast feedback after form actions.

Loading...

Clipboard Copy

Provide feedback when copying content to the clipboard.

Loading...

Undo Delete Action

Implement an undo pattern for destructive actions.

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.