toastvibe
Version:
ToastVibe is a lightweight, customizable, and flexible toast notification library for React.
58 lines (51 loc) • 1.94 kB
TypeScript
import React from 'react';
type ToastType = 'info' | 'success' | 'warning' | 'error' | 'pending';
type ToastPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'top-center' | 'bottom-center';
interface ToastProps {
message: string;
type?: ToastType;
position?: ToastPosition;
onClose?: () => void;
richColors?: boolean;
closeButton?: boolean;
status?: 'pending' | 'completed';
duration?: number;
}
interface ToastContextType {
toasts: ToastProps[];
addToast: (toast: ToastProps) => void;
removeToast: (index: number) => void;
updateToastStatus: (index: number, status: 'pending' | 'completed') => void;
position?: ToastPosition;
richColors?: boolean;
closeButton?: boolean;
className?: string;
duration?: number;
}
declare const ToastContext: React.Context<ToastContextType | null>;
declare const ToastProvider: React.FC<{
children: React.ReactNode;
position?: ToastPosition;
richColors?: boolean;
closeButton?: boolean;
className?: string;
duration?: number;
}>;
declare const ToasterContainer: React.FC<{
position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' | 'top-center' | 'bottom-center';
richColors?: boolean;
closeButton?: boolean;
className?: string;
duration?: number;
children: React.ReactNode;
}>;
declare const useToast: () => ToastContextType;
declare const toast: {
info: (message: string, options?: Partial<ToastProps>) => void;
success: (message: string, options?: Partial<ToastProps>) => void;
warning: (message: string, options?: Partial<ToastProps>) => void;
error: (message: string, options?: Partial<ToastProps>) => void;
pending: (message: string, options?: Partial<ToastProps>) => void;
updateStatus: (index: number, status: "pending" | "completed") => void;
};
export { ToastContext, ToastProvider, ToasterContainer, toast, useToast };