Toast
A customizable and responsive toast notification system...
Installation
npx scrollx-ui@latest add toast
Usage
//First, wrap your application with the ToastProvider:
import { ToastProvider } from "@/components/ui/toast";
function App() {
return (
<ToastProvider>
<YourApp />
</ToastProvider>
);
}
import { useToast } from "@/components/ui/toast";
function MyComponent() {
const { toast } = useToast();
const showToast = () => {
toast({
title: "Success!",
description: "Your action was completed successfully.",
variant: "success",
});
};
return (
<button onClick={showToast}>
Show Toast
</button>
);
}
Examples
Default
Warning
Error
Delete
Info
Success
API Reference
toast
Triggers a toast notification.
title
– Toast titledescription
– Toast messagevariant
–'default' | 'success' | 'destructive' | 'warning' | 'info'
position
–'top-right' | 'top-left' | 'bottom-right' | 'bottom-left'
duration
– Auto-dismiss time in ms (default:5000
)action
– Optional React element (e.g., a button)