Skip to main content
Version: 1.0.3

Toast

The Toast component is a versatile notification system that provides animated, customizable alerts. Built with Framer Motion, it supports multiple variants, animations, themes, and appearance styles, making it perfect for providing feedback in your applications.

Installation

ignix add component toast

Usage

First, wrap your application with the ToastProvider:

import { ToastProvider } from '@ignix-ui/toast';

function App() {
return (
<ToastProvider>
<YourApp />
</ToastProvider>
);
}

Then use the toast in your components:

import {useToast } from '@ignix-ui/toast';

function MyComponent() {
const toast = useToast();

const showNotification = () => {
toast.addToast({
message: "Operation successful!",
variant: "success",
animation: "slide",
mode: "light",
icon: <CheckCircledIcon />
});
};

return <button onClick={showNotification}>Show Toast</button>;
}

Props

ToastProvider Props

PropTypeDefaultDescription
childrenReactNode-Content to wrap with the toast context provider
maxToastsnumber5Maximum number of toasts displayed simultaneously
defaultPosition'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center''top-right'Default screen position for all toasts

ToastDataArgs Props

PropTypeDefaultDescription
messagestring-Text content displayed inside the toast
variant'success' | 'error' | 'warning' | 'info' | 'default'-Visual variant controlling color scheme and default icon
animation'slide' | 'fade' | 'bounce' | 'pop' | 'elastic' | 'flip'-Entry and exit animation style
appearance'glow' | 'gradient' | 'glassmorphism' | 'premium' | 'neon''premium'Visual style treatment applied to the toast surface
mode'dark' | 'light''light'Color mode override for toast text
iconReactNode-Custom icon to replace the default variant icon
durationnumber4000Auto-dismiss delay in milliseconds. Set to 0 to disable
size'sm' | 'md' | 'lg''md'Controls the width and padding of the toast
position'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center'defaultPositionPer-toast position override
showProgressbooleantrueShows an animated progress bar indicating time remaining
pauseOnHoverbooleantruePauses the auto-dismiss timer when hovered
dismissiblebooleantrueRenders a close button to manually dismiss the toast
priority'low' | 'normal' | 'high' | 'urgent''normal'Urgent toasts are pushed to the front of the stack
gradientColorstringvariant colorCustom CSS color used for gradient and glow effects
actionButton{ label: string; onClick: () => void }-Optional inline action button rendered below the message