- Docs
- Components
- Overlays
Toast
A brief word that something happened, at the bottom end. One action at most, such as Undo.
- Import
- @qeetrix/react
- Status
- StableSince 0.0.2
- Renders
<div role="region">Server-rendered- Tested
- WCAG 2.2 AAaxe on every pull request
01
Playground
Every prop, live, and the code it takes.
Tone
import { Button, useToast } from "@qeetrix/react";
const toast = useToast();
<Button
onClick={() => toast.add({ title: "Invoice sent", description: "To finance@acme.in.", tone: "success" })}
>
Send invoice
</Button>02
Tones
Info, success, warning and danger, each with its status edge and icon. Danger stays until it's closed, and is announced at once.
const toast = useToast();
<Button onClick={() => toast.add({ title: "Invoice sent", description: "To finance@acme.in.", tone: "success" })}>Send</Button>03
With Undo
One action at most: Undo, for something just done.
toast.add({
title: "Priya Sharma removed",
tone: "success",
action: { label: "Undo", onClick: () => restore(member) },
});04
While it works
promise: a spinner while it's pending, then success or the reason it failed.
toast.promise(sendInvoice(), {
loading: { title: "Sending the invoice…" },
success: (id) => ({ title: `${id} sent` }),
error: (reason) => ({ title: "Couldn't send it", description: reason.message }),
});05
In Hindi
The region's name and the close button's come from QeetrixProvider.
<QeetrixProvider locale="hi-IN" messages={hi}>
<ToastProvider>…</ToastProvider>
</QeetrixProvider>