Built on Radix UI Toast
Toast
Brief, non-blocking notifications with themed variants, mascot illustrations, actions and spring animations, all driven by a hook.
Playground
import { useChibiToast } from '@chibi-ui/react/toast';
// Somewhere under <ChibiToastProvider>:
const { toast } = useChibiToast();
toast.success("Saved!", {
description: "Your mochi is safe and sound.",
});Import
import {
ChibiToastProvider,
useChibiToast,
} from '@chibi-ui/react/toast';Examples
// app/layout.tsx
import { ChibiToastProvider } from '@chibi-ui/react/toast';
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>
<ChibiToastProvider position="bottom-right">{children}</ChibiToastProvider>
</body>
</html>
);
}const { toast } = useChibiToast();
const id = toast({ title: 'Uploading…', icon: '⏳', duration: Infinity });
try {
await upload(file);
toast.success('Uploaded!', { id });
} catch {
toast.error('Upload failed', { id, description: 'Please try again.' });
}Accessibility
- Toasts are announced through a live region. Errors use assertive (foreground) announcements; the other variants are polite.
- The timer pauses on hover, on focus and when the window loses focus, so users have time to read (WCAG 2.2.1). Errors stay up twice as long.
- F8 (configurable) jumps to the notifications landmark. Toasts close with Esc or a swipe, and every toast has a labelled close button.
- Actions need altText, which describes another way to do the same thing for people who cannot reach the toast in time.
API reference
ChibiToastProvider
| Prop | Type | Default | Description |
|---|---|---|---|
| position | 'top-right' | 'top-center' | 'bottom-right' | 'bottom-center' | 'bottom-right' | Where the stack is anchored. The swipe direction follows. |
| duration | number | 5000 | Default auto-dismiss in ms. |
| limit | number | 3 | Max visible toasts; oldest are dropped. |
| label | string | 'Notifications' | Landmark label. |
| hotkey | string[] | ['F8'] | Jump-to-notifications shortcut. |
toast(options) / toast.success(title, options)
| Prop | Type | Default | Description |
|---|---|---|---|
| title | ReactNode | — | Required headline. |
| description | ReactNode | — | Supporting text. |
| variant | 'success' | 'warning' | 'error' | 'info' | 'info' | Colour, mascot mood and urgency. |
| duration | number | — | Override auto-dismiss; Infinity to persist. |
| action | { label, altText, onClick } | — | Optional action button. |
| icon | ReactNode | false | — | Replace the mascot (e.g. an emoji) or hide it. |
| id | string | — | Re-use to update a toast in place. Returned by toast(). |