Toast
Toast is used to display a message to the user. They are usually displayed at the top of the screen and disappear after a few seconds.
You can also have an unstyled toast with a custom component. This is useful if you want to have a toast with a custom layout.
Blank role will not apply anything to the toast, which means you'll need to handle the dismiss
button yourself.
Prop | Default | Description |
---|---|---|
title | string Title of the toast | |
message | string Message to display in the toast. Note: If component is provided, message will be ignored | |
role | 'default' | 'success' , 'error' , 'info' , 'warning' , 'default' , 'blank' Role of the toast |
id | The id of the toast | |
autoDismiss | true | boolean Whether to auto dismiss the toast |
duration | 4000 | number Duration in milliseconds to auto dismiss the toast |
component | null | ({ dismiss }: { dismiss: () => void }) => ReactNode Component to render in the toast |
dismissIcon | XMarkIcon | any Icon to use for the dismiss button |
onDismiss | null | ({ id, role }: { id: string; role: string }) => void Callback function to run when the toast is dismissed |
icon | null | JSX.Element | ((props: any) => JSX.Element) Icon to render in the toast. If not provided, the icon will be based on the role |
dismissClassName | string Class name to apply to the dismiss button |