UNPKG

react-high-toast

Version:

A highly customizable toast notification system for React using portals

25 lines (24 loc) 840 B
/// <reference types="react" /> export type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'; export type ToastType = 'success' | 'error' | 'warning' | 'info' | 'default'; export interface ToastOptions { id?: string; type?: ToastType; duration?: number; position?: ToastPosition; render?: (toast: IToast) => React.ReactNode; } export interface IToast { id: string; message: string | React.ReactNode; createdAt: number; type: ToastType; duration: number; position: ToastPosition; render?: (toast: IToast) => React.ReactNode; } export interface ToastContextType { toasts: IToast[]; addToast: (message: string | React.ReactNode, options?: ToastOptions) => string; removeToast: (id: string) => void; }