AsterUIDocsv1.0.2

Docs / Component reference

Toast & Toaster

Confirm a short-lived outcome, such as a saved draft, while the user stays on the same page.

Toast example

Install

sh
npx @fierst/ui@1.0.2 add toast

Registry dependencies: theme, icon. Package dependencies: @lucide/icons.

Exports from ./ui/toast: ToastTone, ToastItem, dismissToast, showToast, toast, Toaster.

Download the registry source for toast 1.0.2.

API contracts

ts
export type ToastTone = 'neutral' | 'success' | 'warning' | 'danger';

export interface ToastItem {
  id: string;
  title: string;
  description?: string;
  tone: ToastTone;
}

export function dismissToast(id: string): void

export function showToast(
  title: string,
  opts: { description?: string; tone?: ToastTone; duration?: number } = {},
): string

export const toast = {
  show: (title: string, description?: string) => showToast(title, { description, tone: 'neutral' }),
  success: (title: string, description?: string) =>
    showToast(title, { description, tone: 'success' }),
  warning: (title: string, description?: string) =>
    showToast(title, { description, tone: 'warning' }),
  error: (title: string, description?: string) => showToast(title, { description, tone: 'danger' }),
  dismiss: dismissToast,
};

export function* Toaster()