Toast

GitHub

Color-coded toast provider and helper for notifications, including feedback from ActionResult values.

Installation

bash
pnpm dlx shadcn@latest add @cs/toast

Usage

tsx
import { Toaster, toast } from "@/components/cs/toast";
tsx
<Toaster />;
toast.loading("Saving changes...");

API Reference

Toaster

Renders color-coded info, success, warning, error, and loading notifications.

toast

Notification helper for application-level toast messages.

Methods

tsx
toast.info(message: string, options?: ToastOptions): void

Shows an informational notification.

tsx
toast.success(message: string, options?: ToastOptions): void

Shows a success notification.

tsx
toast.warning(message: string, options?: ToastOptions): void

Shows a warning notification.

tsx
toast.error(message: string, options?: ToastOptions): void

Shows an error notification.

tsx
toast.loading(message: string, options?: ToastOptions): void

Shows a loading notification with a spinning indicator.

tsx
toast.dismiss(id: string): void
tsx
toast.actionResult({ status, message, toast }: ActionResult, options?: ToastOptions): void

Shows feedback from an ActionResult, respecting its optional toast variant.