Toast
The toast is used to show alerts on top of an overlay. The toast will close itself when the close button is clicked, or after a timeout — the default is 5 seconds. The toast component is used to give feedback to users after an action has taken place.
Toasts can be configured to appear at either the top or the bottom of an application window, and it is possible to have more than one toast onscreen at a time.
Import
Usage
In order to use Toast, you need to put this at the top of your App once
Editable Example
Editable Example
Custom component
Display a custom component instead of the default Toast UI. The native
option will not work using this method.
Editable Example
Success
Editable Example
Warning
Editable Example
Error
Error toasts are persisted by default.
Editable Example
Native notifications
Using the native
prop you can also spawn a native browser notification, where supported. This is useful if the user has left a long running process and you want to alert them.
Editable Example
Position
Using the position
prop you can adjust where your toast will be popup from.
Editable Example
Props
Name | Type | Default | Description |
---|---|---|---|
title | string | The title of the toast. | |
closeable | boolean | true | If true adds a close button to the toast. |
onClose | function | Callback function to close the toast. | |
description | React.ReactNode | The description of the toast. | |
appearance | success , error , warning , info | The status of the toast. | |
duration | number | 5000ms | Duration before dismiss in milliseconds, or null to never dismiss. |
position | top-center , top-left , top-right , bottom-center , bottom-left , bottom-right | bottom | Position the toast will popup out from. |
render | (props: {onClose:() => void, id: string}) => React.ReactNode | The description of the toast. | |
native | boolean | false | Whether to send a native browser notification along with the toast. |