suiss/ui · Component
Toast
Brief, stacked notifications that appear at the bottom of the screen and dismiss themselves.
Toast is an open-source component from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
Toasts are built on the Base UI Toast primitive. Toaster is the ready-made setup: it combines ToastProvider, ToastPortal and ToastViewport, and renders each queued toast as a Toast with a ToastContent row holding a status icon, ToastTitle, ToastDescription, ToastAction and ToastClose.
New toasts stack at the bottom of the screen, with older ones scaled down behind, and expand into a list on hover or focus. Use toasts for short confirmations and background results; for messages that need a decision, use AlertDialog.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Usage
Examples
Types
Set type to success, info, warning or error to add a colored status icon, or to loading for a progress ring.
Title only
Shows a toast with a title and no description.
With action
Pass actionProps to show a ToastAction button. This one is an Undo action that closes the toast.
Timeout
Set timeout in milliseconds to change how long a toast stays; 0 keeps it until it is closed.
Promise toast
toast.promise(promise, { loading, success, error }) shows a loading toast that turns into the success toast when the promise resolves.
Promise rejected
Uses toast.promise to move from loading to an error when the promise rejects.
Accessibility
- The viewport is a
regionlandmark namedNotifications. - Each toast has the
dialogrole, named by its title and described by its description. ToastClosehas the accessible nameClose toast.- Prefer an action that can also be reached elsewhere, since toasts dismiss themselves after their timeout.
API Reference
ToastProvider
Provides a toast manager to the parts inside it.
Also accepts the props of the primitive part it wraps.
ToastPortal
Renders the viewport into a portal.
Also accepts the props of the primitive part it wraps.
ToastViewport
The fixed region at the bottom of the screen that holds the stack.
Also accepts the props of the primitive part it wraps.
On small screens the stack is centered at the bottom, inset from the edges and up to max-w-sm wide; from the sm breakpoint it sits in the bottom end corner.
Toast
A single toast in the stack, positioned and animated by its index.
Also accepts the props of the primitive part it wraps.
Toasts can be swiped away; the exit animation follows the swipe direction.
ToastContent
The row that lays out a toast's icon, text and buttons.
Also accepts the props of the primitive part it wraps.
ToastTitle
The toast's title, which names it.
Also accepts the props of the primitive part it wraps.
ToastDescription
Supporting text, which describes the toast.
Also accepts the props of the primitive part it wraps.
ToastAction
An optional action button, rendered as a small outline Button.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
Also accepts the props of the primitive part it wraps.
ToastClose
An icon button that dismisses the toast.
| Prop | Type | Default |
|---|---|---|
asChild | boolean | false |
Also accepts the props of the primitive part it wraps.
Toaster
The complete setup: provider, portal, viewport and the rendered toasts.
| Prop | Type | Default |
|---|---|---|
toastManager | ReturnType<typeof createToastManager> | toast |
Also accepts the props of ToastProvider.
Render Toaster once near the root of your app, wrapping the content that shows toasts. Call toast.add({ title, description, type }) from anywhere, or read the manager inside the tree with useToastManager(). add returns an id that you can pass to close; close() with no id closes every toast.
Toaster uses the shared toast manager by default. Pass toastManager a manager from createToastManager() to keep a separate stack. Use the individual parts only to build a custom toast list.
Each part sets a data-slot, such as toast-viewport or toast-close, for styling. The loading ring's progress animation is removed when reduced motion is preferred.
Web preview
Add .toaster() once near the root. It overlays the toast stack at the bottom of the view and puts its ToastManager in the environment as toastManager. Call show, success, info, warning, error or loading to add a toast, update to change it and dismiss to remove it.
Toaster wraps your app in a toast provider and renders the queue into a full-screen viewport. Each toast slides in from the bottom edge, fades out downward, and is capped at 384 points wide.
Create the state with rememberToastState() and wrap your content in Toaster. Call show, success, info, warning, error or loading on the state to add a toast, update to change it and dismiss to remove it.
The viewport renders through a portal. On iOS it sits inside a FullWindowOverlay from react-native-screens, so toasts appear above native modals. Each toast is a Reanimated view.
Visible toasts stack with a small peek and shrink behind the frontmost one. Touching the stack expands it; it collapses again three seconds after the touch ends. Each toast shows an icon for its type (success, info, warning, error, or a spinner for loading), a title, a description, an optional action button and a close button.
Installation
- Install the following dependencies:
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/toast.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/toast.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy the primitives it uses into
components/primitives:
- Copy and paste the following code into
components/ui/toast.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.
Usage
Examples
Show on load
Shows a success toast as soon as the screen mounts.

The React Native tab shows 1 more example.
The React Native tab shows 1 more example.
Accessibility
- Each toast has the
alertrole and a live region that ispolite, orassertiveforpriority: "high". - New toasts are announced with their title and description; high-priority announcements are not queued.
- A
dismissaccessibility action and the escape gesture close the toast. - Toasts stacked behind the front one are hidden from VoiceOver and TalkBack.
- The close button has the label "Close toast" and the type icon is hidden from assistive technology.
- Animations respect the system reduce motion setting.
API Reference
ToastProvider
Holds the toast queue, default timeout and visible limit.
Also accepts the props of ToastPrimitive.ProviderProps.
ToastPortal
Renders its children into a portal host.
Also accepts the props of ToastPrimitive.PortalProps.
ToastViewport
Full-screen layer that holds the stack and expands it on touch.
Also accepts the props of React.ComponentProps<typeof ToastPrimitive.Viewport>.
Toast
One animated, swipeable toast in the stack.
Also accepts the props of React.ComponentProps<typeof ToastPrimitive.Root>.
ToastContent
Row layout for the icon, text, action and close button.
Also accepts the props of React.ComponentProps<typeof ToastPrimitive.Content>.
ToastTitle
The toast title, read from the toast object.
Also accepts the props of React.ComponentProps<typeof ToastPrimitive.Title>.
ToastDescription
Secondary text under the title.
Also accepts the props of React.ComponentProps<typeof ToastPrimitive.Description>.
ToastAction
Outline button rendered from actionProps.
Also accepts the props of React.ComponentProps<typeof ToastPrimitive.Action>.
ToastClose
Icon button that dismisses the toast.
Also accepts the props of React.ComponentProps<typeof ToastPrimitive.Close>.
Toaster
Provider, portal and viewport that render the default toast list.
| Prop | Type | Default |
|---|---|---|
portalHost | string | - |
Also accepts the props of ToastPrimitive.ProviderProps.
Render Toaster once near the root, then call the exported toast manager from anywhere: toast.add({ title, description, type }) returns an id, toast.update(id, updates) changes a toast, and toast.close(id) removes it (or all toasts when called without an id). toast.promise(promise, { loading, success, error }) shows a loading toast and replaces it with the success or error state when the promise settles.
Pass actionProps (for example { children: "Undo", onPress }) to show an action button. Set priority: "high" for urgent messages and timeout to override the provider default; loading toasts stay until updated.
Use createToastManager to create a separate manager and pass it to Toaster as toastManager, and useToastManager to read the current toasts and actions inside the provider. The lower-level parts are exported for building a custom toast layout. portalHost names the portal host to render into.
Toasts respect the bottom safe area inset. FullWindowOverlay is used on iOS only; Android renders the viewport directly. In dark mode the toast has no border.
ToastType
Values: .default, .success, .info, .warning, .error, .loading.
ToastAction
| Parameter | Type | Default |
|---|---|---|
_ title | LocalizedStringResource | - |
action | () -> Void | - |
| Property | Type |
|---|---|
title | LocalizedStringResource |
action | @MainActor @Sendable () -> Void |
ToastItem
| Property | Type |
|---|---|
id | UUID |
type | ToastType |
title | LocalizedStringResource |
description | LocalizedStringResource? |
action | ToastAction? |
duration | Duration? |
ToastManager
Takes no parameters.
| Property | Type |
|---|---|
static shared | ToastManager |
toasts | [ToastItem] |
limit | Int |
ToastManager.show
| Parameter | Type | Default |
|---|---|---|
_ title | LocalizedStringResource | - |
description | LocalizedStringResource? | nil |
type | ToastType: .default | .success | .info | .warning | .error | .loading | .default |
action | ToastAction? | nil |
duration | Duration? | .seconds(5) |
Returns UUID.
ToastManager.success
| Parameter | Type | Default |
|---|---|---|
_ title | LocalizedStringResource | - |
description | LocalizedStringResource? | nil |
action | ToastAction? | nil |
Returns UUID.
ToastManager.info
| Parameter | Type | Default |
|---|---|---|
_ title | LocalizedStringResource | - |
description | LocalizedStringResource? | nil |
action | ToastAction? | nil |
Returns UUID.
ToastManager.warning
| Parameter | Type | Default |
|---|---|---|
_ title | LocalizedStringResource | - |
description | LocalizedStringResource? | nil |
action | ToastAction? | nil |
Returns UUID.
ToastManager.error
| Parameter | Type | Default |
|---|---|---|
_ title | LocalizedStringResource | - |
description | LocalizedStringResource? | nil |
action | ToastAction? | nil |
Returns UUID.
ToastManager.loading
| Parameter | Type | Default |
|---|---|---|
_ title | LocalizedStringResource | - |
description | LocalizedStringResource? | nil |
Returns UUID.
ToastManager.update
| Parameter | Type | Default |
|---|---|---|
_ id | UUID | - |
title | LocalizedStringResource? | nil |
description | LocalizedStringResource? | nil |
type | ToastType?: .default | .success | .info | .warning | .error | .loading | nil |
duration | Duration? | .seconds(5) |
ToastManager.dismiss
| Parameter | Type | Default |
|---|---|---|
_ id | UUID | - |
ToastManager.dismissAll
Takes no parameters.
.toaster
| Parameter | Type | Default |
|---|---|---|
_ manager | ToastManager | .shared |
ToastType
Values: Default, Success, Info, Warning, Error, Loading.
ToastAction
| Parameter | Type | Default |
|---|---|---|
label | String | - |
onClick | () -> Unit | - |
ToastState
| Parameter | Type | Default |
|---|---|---|
limit | Int | 3 |
defaultDurationMillis | Long | 5000 |
| Property | Type |
|---|---|
toasts | List<ToastData> |
ToastState.show
| Parameter | Type | Default |
|---|---|---|
title | String | - |
description | String? | null |
type | ToastType: Default | Success | Info | Warning | Error | Loading | ToastType.Default |
action | ToastAction? | null |
durationMillis | Long | if (type == ToastType.Loading) 0 else defaultDurationMillis |
Returns Long.
ToastState.success
| Parameter | Type | Default |
|---|---|---|
title | String | - |
description | String? | null |
action | ToastAction? | null |
Returns Long.
ToastState.info
| Parameter | Type | Default |
|---|---|---|
title | String | - |
description | String? | null |
action | ToastAction? | null |
Returns Long.
ToastState.warning
| Parameter | Type | Default |
|---|---|---|
title | String | - |
description | String? | null |
action | ToastAction? | null |
Returns Long.
ToastState.error
| Parameter | Type | Default |
|---|---|---|
title | String | - |
description | String? | null |
action | ToastAction? | null |
Returns Long.
ToastState.loading
| Parameter | Type | Default |
|---|---|---|
title | String | - |
description | String? | null |
Returns Long.
ToastState.update
| Parameter | Type | Default |
|---|---|---|
id | Long | - |
title | String? | null |
description | String? | null |
type | ToastType?: Default | Success | Info | Warning | Error | Loading | null |
action | ToastAction? | null |
durationMillis | Long? | null |
ToastState.dismiss
| Parameter | Type | Default |
|---|---|---|
id | Long | - |
ToastState.dismissAll
Takes no parameters.
rememberToastState
| Parameter | Type | Default |
|---|---|---|
limit | Int | 3 |
defaultDurationMillis | Long | 5000 |
Returns ToastState.
Toaster
Provider, portal and viewport that render the default toast list.
| Parameter | Type | Default |
|---|---|---|
state | ToastState | - |
modifier | Modifier | Modifier |
content | @Composable () -> Unit | {} |
