Toasts
Toast notifications in five colors with actions, plus the useToasts hook and Toaster to manage a stack of messages.
How to use it
Run npx @blossomui/react add toast, or copy src/components/UI/Toasts/Toast.tsx into your React project and import it.
import { Toast, useToasts, Toaster } from './components/ui/Toast'
Props
ToastProps
| Prop | Type | Description |
|---|
| dismissLabel | string | Accessible name of the dismiss button. |
| color | ToastColor | (string & {}) | A preset, `accent` for the brand color or any CSS color. A custom color fills the toast and the text switches between black and white to stay readable. |
| children (required) | ReactNode | |
| actionLabel | string | Text of the action button, for example "Undo". |
| onAction | () => void | |
| onDismiss | () => void | |
ToastItem
| Prop | Type | Description |
|---|
| id (required) | number | |
| message (required) | string | |
| duration (required) | number | Milliseconds before it closes by itself. Use 0 to keep it until dismissed. |
ToasterProps
| Prop | Type | Description |
|---|
| toasts (required) | ToastItem[] | |
| onDismiss (required) | (id: number) => void | |
| dismissLabel | string | Accessible name of the close button of every toast. |
| position | ToasterPosition | Corner of the screen. Use a top one if the toasts hide the buttons at the bottom of a dialog. |
| className | string | Classes for the container. They replace the ones of `position`. |