No provider to mount, no hook to declare. Import toast and call it.
Experience different notification styles and interactions
Try it: hover a toast to pause its timer, press Alt + T to focus the newest one, then Esc to dismiss it.
npm install react-compact-toastyarn add react-compact-toastpnpm add react-compact-toastimport { ToastContainer, toast } from 'react-compact-toast';
export default function App() {
return (
<>
<button onClick={() => toast.success('Saved')}>
Save
</button>
<ToastContainer />
</>
);
}// Semantic variants
toast.success('Saved');
toast.error('Could not save');
// Follow a promise from start to finish
toast.promise(save(), {
loading: 'Savingโฆ',
success: (draft) => `Saved as ${draft.title}`,
error: (err) => `Could not save: ${err.message}`,
});
// Update a toast in place, or give it an action
const id = toast.loading('Uploadingโฆ');
toast.update(id, { type: 'success', text: 'Uploaded', autoClose: 3000 });
toast('Message archived', {
action: { label: 'Undo', onClick: restore },
});
// 'topLeft' | 'topCenter' | 'topRight' |
// 'bottomLeft' | 'bottomCenter' | 'bottomRight'๐ฏ Pro Tip: You can fully style your toasts using className โ Tailwind, Emotion, Vanilla CSS, or plain CSS โ it's all up to you!