Toast
A short confirmation at the bottom right, with an undo.
import { Toaster, useToast } from "@forgeron/ui";import { Button, Toaster, useToast } from "@forgeron/ui";
function Actions() {
const toast = useToast();
return (
<>
<Button
onClick={() =>
toast.add({
title: "OPS-40 deleted",
actionProps: {
children: "Undo",
onClick: () => toast.add({ title: "OPS-40 restored" }),
},
})
}
>
Delete issue
</Button>
<Button onClick={() => toast.add({ title: "crm 1.4.0 is live", type: "success" })}>
Deploy
</Button>
<Button
onClick={() =>
toast.add({
title: "The deploy failed",
description: "Type error in src/actions.ts.",
type: "danger",
priority: "high",
})
}
>
Fail
</Button>
</>
);
}
export default function Undo() {
return (
<Toaster>
<Actions />
</Toaster>
);
}API → Props
| Prop | Type | Default | Description |
|---|---|---|---|
limit (Toaster) | number | 3 | How many show at once. |
add (useToast) | ({ title, description?, type?, actionProps?, timeout? }) => id | — | Shows one. |
type | "success" | "danger" | — | The mark on its left edge. |
className | string | — | Extra classes. |