Skip to content
ChibiUI

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

Generated code
import { useChibiToast } from '@chibi-ui/react/toast';

// Somewhere under <ChibiToastProvider>:
const { toast } = useChibiToast();

toast.success("Saved!", {
  description: "Your mochi is safe and sound.",
});

Import

TSX
import {
  ChibiToastProvider,
  useChibiToast,
} from '@chibi-ui/react/toast';

Examples

1 · Mount the provider once
// 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>
  );
}
2 · Update a toast in place
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

PropTypeDefaultDescription
position'top-right' | 'top-center' | 'bottom-right' | 'bottom-center''bottom-right'Where the stack is anchored. The swipe direction follows.
durationnumber5000Default auto-dismiss in ms.
limitnumber3Max visible toasts; oldest are dropped.
labelstring'Notifications'Landmark label.
hotkeystring[]['F8']Jump-to-notifications shortcut.

toast(options) / toast.success(title, options)

PropTypeDefaultDescription
titleReactNode—Required headline.
descriptionReactNode—Supporting text.
variant'success' | 'warning' | 'error' | 'info''info'Colour, mascot mood and urgency.
durationnumber—Override auto-dismiss; Infinity to persist.
action{ label, altText, onClick }—Optional action button.
iconReactNode | false—Replace the mascot (e.g. an emoji) or hide it.
idstring—Re-use to update a toast in place. Returned by toast().