Toast
An imperative API, like Sonner: call toast(...) from anywhere in your code, no context provider needed at the call site. Mount <ToastViewport /> once, near the root of your app, to actually render them. Every toast is its own live region, role="alert" for danger/warning, role="status" for default/success, the same reasoning as Alert.
Usage
import { Button, ToastViewport, toast } from "@kernelui/react";
function SaveButton() {
return (
<>
<Button onClick={() => toast.success("Changes published")}>Publish</Button>
<ToastViewport />
</>
);
}API
| Call | Notes |
|---|---|
toast(title, options?) | Default variant |
toast.success(title, options?) | — |
toast.warning(title, options?) | — |
toast.danger(title, options?) | — |
toast.dismiss(id) | Dismiss a specific toast early |
options: { description?, duration? }. duration defaults to 4000ms; pass 0 to require a manual dismiss.