Skip to content

Toast

A toast is a non-blocking notification commonly used to provide feedback to the user after an action has been taken. This component is a wrapper around the React Hot Toast library.

React Hot Toast Documenation

Import

Terminal window
import { toast, Toaster } from "@aeonkit/react";

Usage

Default

Using Options

You can pass in any React Hot Toast options to the toast function via options . Refer to the React Hot Toast documentation for more information.

Loading

Set the status prop to loading to display a loading spinner in the toast that will load indefinitely. The toast is not dismissible by default when the status is set to loading. Use toast.dismiss() to dismiss the toast.

Custom Content

You can pass in custom content to the toast function via the render prop. The render function receives the toast and dismiss functions as arguments.

Custom Icons

You can pass in custom status and close icons to the toast function via options.icon and closeIcon respectively.

Styling

You can pass in custom classes to the toast function via options.className.

Animations

You can pass in custom transitions to the toast function via transitions. Refer to the Headless UI Transitions documentation for more information.

API

toast

title?

ReactNode

The title of the toast.

description?

ReactNode

The content of the toast.

status?

"success" "error" "warning" "info" "loading"

The status of the toast. Determines the icon of the toast.

Default: info

render?

(toast: HotToast, dismiss: (toastId?: string) => void) => ReactNode

A function that returns the content of the toast. Use this to render custom content.

options?

HotToastOptions

The options to configure the toast. Refer to the React Hot Toast documentation for more information.

closable?

boolean

Whether the toast can be dismissed by the user.

closeIcon?

ReactNode

The icon to use for the close button.

transitions?

TransitionProps

The transitions to use for the toast. Refer to the Headless UI Transitions documentation for more information.

toast.remove

This method removes a specific toast via a toast ID without any animations instantly. Refer to the React Hot Toast documentation for more information.

Remove toasts instantly
toast.remove()
// or
toast.remove(toastId)

toast.dismiss

This method dismisses all toast or a specific toast via a toast ID. Refer to the React Hot Toast documentation for more information.

Dismiss toasts
toast.dismiss()
// or
toast.dismiss(toastId)

Toaster Props

API Interface: ToasterProps