Components

Toast

The toast is a non-disruptive message that provides feedback after an action has taken place. The toast will close itself when the close button is clicked, or after a timeout.

For critical or persistent error messages, or to communicate a state that affects a system, feature or page, use the alert component.

For critical messages requiring immediate action, use an alert dialog.

Import

import { useToast } from '@outfitio/outkit';

Usage

Success

Warning

Error

Position

Using the position prop you can adjust where your toast will be popup from.

Accessibility

  • Avoid using a toast for critical information that requires immediate action.

Best Practice

Toast messages can be used for:

  • Short messages that confirm an action, such as a success messages
  • Non-critical errors that are relevant in the moment an be explained in a couple of words

Toasts should not be used for:

Props

NameTypeDefaultDescription
titlestringThe title of the toast.
isClosablebooleanfalseIf true adds a close button to the toast.
onClosefunctionCallback function to close the toast.
descriptionstringThe description of the toast.
statussuccess, error, warning, infoThe status of the toast.
durationnumber5000msDuration before dismiss in milliseconds, or null to never dismiss.
positiontop, top-left, top-right, bottom, bottom-left, bottom-rightbottomPosition the toast will popup out from.
render(props: {onClose:() => void, id: string}) => React.ReactNodeThe description of the toast.