npm install preact-toast
import toast, { Toaster } from 'preact-toast';
const notify = () => toast('Here is your toast.');
const App = () => {
return (
<div>
<button onClick={notify}>Make me a toast</button>
<Toaster />
</div>
);
};
toast
toast(message: string) // <- 3000ms and top-right
toast(message: string, ms: number) // <- custom ms and top-right
toast(message: string, config: ToastConfig) // <- custom toast (look src/types.ts)
Toaster
<Toaster
position="top-right" // <- default toast-position
style={} // <- default toast-style
className={} // <- default toast-class
/>
- preact-toast - MIT
- preact - MIT