<Toaster /> API
Render one <Toaster /> near the root of your application. It subscribes to toast state and displays the active stack.
Import
import { Toaster } from 'react-stacked-toast/toaster';
You can also import Toaster from the root package:
import { Toaster } from 'react-stacked-toast';
Available options
import { Toaster } from 'react-stacked-toast/toaster';<Toasterposition="right"toastOptions={{duration: 3 * 1000,icon: '👋',toastLimit: 3,style: {backgroundColor: '#333',color: '#fff',},className: 'toast',viewportStyle: {top: 24,},viewportClassName: 'toast-viewport',}}/>;
| Prop | Type | Default | Description |
|---|---|---|---|
position | 'right' | 'center' | 'left' | 'right' | The position of the toaster on the screen. |
toastOptions | object | {} | Options for customizing the appearance of toasts |
toastOptions option | Type | Description |
|---|---|---|
duration | number | The duration of each toast in milliseconds. Default is 3000 |
icon | ReactNode | The default icon for toast notifications. |
style | CSSProperties | Inline styles applied to each toast. |
className | string | A class name applied to each toast. |
toastLimit | number | The maximum number of visible toasts. Default is 3. |
viewportStyle | CSSProperties | Inline styles applied to the toast viewport. |
viewportClassName | string | A class name applied to the toast viewport. |
Usage
import { Toaster } from 'react-stacked-toast/toaster';export const App = () => (<><Toaster position="right" />{/* Other components */}</>);