meowerse_
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

demo source
tsx
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

proptypedefaultrequired
childrenReactNode the app rendered under the provider; toasts render alongside it.—yes

css custom properties

variabledarklight
--c-danger#ff6b63#b42318
--c-fg#ededeb#1a1a1c
--c-line-strong#404044#a9a8a2
--c-ok#3ddc84#11652f
--c-surface-raised#1a1a1d#f7f6f3
--fs-30.875remsame
--r-m4pxsame
--shadow-md0 8px 24px rgb(0 0 0 / 0.25) (legacy alias)—
--sp-28pxsame
--sp-312pxsame
--sp-416pxsame
--z-toast40same

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.