docs menu
ToastProvider
Short notices that appear at the bottom of the screen and go away on their own; useToast() shows one.
import { ToastProvider } from "@meowerse/ui"; · source packages/ui/src/components/Toast.tsx
try it
working: loading the demo…
demo source
import { Button, ToastProvider, useToast } from "@meowerse/ui";
function Buttons() {
const push = useToast();
return (
<div className="btn-row">
<Button onClick={() => push({ message: "message sent", variant: "success", duration: 6000 })}>success</Button>
<Button onClick={() => push({ message: "couldn't send — it will retry when you're back online", variant: "error", duration: 6000 })}>error</Button>
<Button onClick={() => push({ message: "3 new messages", duration: 6000 })}>info</Button>
</div>
);
}
export default function Demo() {
return <ToastProvider><Buttons /></ToastProvider>;
}
props
| prop | type | default | required |
|---|---|---|---|
children | ReactNode the app rendered under the provider; toasts render alongside it. | — | yes |
css custom properties
| variable | dark | light |
|---|---|---|
--c-danger | #ff6b63 | #b42318 |
--c-fg | #ededeb | #1a1a1c |
--c-line-strong | #404044 | #a9a8a2 |
--c-ok | #3ddc84 | #11652f |
--c-surface-raised | #1a1a1d | #f7f6f3 |
--fs-3 | 0.875rem | same |
--r-m | 4px | same |
--shadow-md | 0 8px 24px rgb(0 0 0 / 0.25) (legacy alias) | — |
--sp-2 | 8px | same |
--sp-3 | 12px | same |
--sp-4 | 16px | same |
--z-toast | 40 | same |
Classes: .mw-toast, .mw-toasts. Set any of these variables on an ancestor (or wrap a subtree in .mw-theme--dark / .mw-theme--light) to restyle just that part of a page.
accessibility
- Toasts appear in a polite live region labelled "notifications".
- Variants differ by border colour only, and toasts can't be paused or dismissed yet (audit U-13); keep them short and never the only place an error is shown.
do and don't
do
- Confirm something that just happened: "message sent".
don't
- Don't put actions or long text in a toast.