Brand Guide

Components

Toast

A short message that appears at the top right to confirm an action, then goes away.

Default

With a description

Types

With an action

One at a time

Toasts with the same id replace each other. Press the button several times: there is still one toast.

Setting it up

An app mounts one Toaster in its providers, inside the theme provider so it follows light and dark. It needs no props: success, error, warning and info toasts take their colour by default. After that, any client code calls toast() from @dex/shared/components/toast. Toasts appear at the top right.

Best practices

  • A toast reports something that has already happened: "Role saved", "Application sent". Call it from the handler once the request has succeeded or failed, not when the button is pressed.
  • Use the type that fits: toast.success when the action worked, toast.error when it failed, toast.info for news that is neither. Each has its own icon.
  • Give a toast an id when the same event can fire more than once, so it is shown once.