Toast - Skeleton

Skeleton

  1. components
  2. toast
  3. react

Toast

Build a toast notification system.

The first example showcases the complete setup process for a reusable toast component, while the following are abridged to handle everything in a single file. Please keep this in mind when following these examples.

Trigger Methods

Use the generic create() method to trigger toasts of type: info|success|warning|error.

toaster.create({
type: 'info',
message: 'This is a toast',
description: 'This is a toast description.'
});

Additonally, four shorthand methods are available for specific toast types.

  • info()
  • success()
  • warning()
  • error()

Placement

Provide a placement option for createToaster(). Accepts the following:

  • top-start
  • top-end
  • bottom-start
  • bottom-end

Closable

Set closable to false to disable the close button toasts.

Promise

Use promise() to create a toast configured based on the state of a promise. The toast will automatically update based on the state of the promise.

Styling for React 18

For React 18 add these styles to your global stylesheet. For React 19+, these styles are set automatically.

styles.css
[data-scope='toast'][data-part='root'] {
translate: var(--x) var(--y);
scale: var(--scale);
z-index: var(--z-index);
height: var(--height);
opacity: var(--opacity);
will-change: translate, opacity, scale;
}
[data-scope='toast'][data-part='root'] {
transition:
translate 400ms,
scale 400ms,
opacity 400ms;
transition-timing-function: cubic-bezier(0.21, 1.02, 0.73, 1);
}
[data-scope='toast'][data-part='root'][data-state='closed'] {
transition:
translate 400ms,
scale 400ms,
opacity 200ms;
transition-timing-function: cubic-bezier(0.06, 0.71, 0.55, 1);
}

API Reference

Toaster

Property Type Description
toaster *
base
string
Provide base classes for the root element.
width
string
Provide width classes for the root element.
padding
string
Provide padding classes for the root element.
rounded
string
Provide border radius classes for the root element.
classes
string
Provide arbitrary classes for the toast cards.
messageBase
string
Provide base classes for the message.
messageClasses
string
Provide classes for the message.
titleBase
string
Provide base classes for the title.
titleClasses
string
Provide classes for the title.
descriptionBase
string
Provide base classes for the description.
descriptionClasses
string
Provide classes for the description.
btnDismissBase
string
Provide base classes for the dismiss button.
btnDismissClasses
string
Provide arbitrary classes for the dismiss button.
stateInfo
string
Provide base classes for info toasts.
stateSuccess
string
Provide base classes for success toasts.
stateWarning
string
Provide base classes for warning toasts.
stateError
string
Provide base classes for error toasts.

Toast

Property Type Description
toast *
parent *
base
string
Provide base classes for the root element.
width
string
Provide width classes for the root element.
padding
string
Provide padding classes for the root element.
rounded
string
Provide border radius classes for the root element.
classes
string
Provide arbitrary classes for the toast cards.
messageBase
string
Provide base classes for the message.
messageClasses
string
Provide classes for the message.
titleBase
string
Provide base classes for the title.
titleClasses
string
Provide classes for the title.
descriptionBase
string
Provide base classes for the description.
descriptionClasses
string
Provide classes for the description.
btnDismissBase
string
Provide base classes for the dismiss button.
btnDismissClasses
string
Provide arbitrary classes for the dismiss button.
stateInfo
string
Provide base classes for info toasts.
stateSuccess
string
Provide base classes for success toasts.
stateWarning
string
Provide base classes for warning toasts.
stateError
string
Provide base classes for error toasts.

Alternatives

If you’re looking for power user features or more control over templates, consider using React-Hot-Toast.