Toast Notification
A succinct message that is displayed temporarily in a corner of the screen. Built with Radix UI primitives and Framer Motion for high-quality interactions, it supports default and destructive variants, titles, and descriptions.
ui@radix-ui/react-toastclass-variance-authorityframer-motionlucide-react
Installation
$npx futureuikit add toast
Import
import { ToastProvider } from "@/components/ui/toast"
Layout Variant
Color Theme
Position
Shape
Text & Icon Size
Spacing / Padding
Named Keys & Props
Pass these exact named keys as props on <ToastProvider />. Click any color pill to copy the prop.
colorDefault is "default"(Black & White)variantVisual style"solid""outline""ghost""glass""elevated""soft""destructive"shapeCorner shape"default""square""rounded""sharp"spacingInner spacing"default""2x""4x""6x""8x"sizeComponent size"default""sm""md""lg""xl"Usage Example
A basic implementation example to get you started.
Example Implementation
import { useToast } from "@/hooks/use-toast";
import { Button } from "@/components/ui/button";
export default function Example() {
const { toast } = useToast();
return (
<Button
onClick={() => {
toast({
title: "Scheduled: Catch up",
description: "Friday, February 10, 2024 at 5:57 PM",
});
}}
>
Show Toast
</Button>
);
}Features
Key capabilities and highlights.
Key Capabilities
- ◆Built with Radix UI Toast primitives for accessibility.
- ◆Supports Default and Destructive variants.
- ◆Animated with Framer Motion for smooth entry and exit.
- ◆Customizable titles, descriptions, and action buttons.
- ◆Auto-dismiss functionality with configurable delays.
- ◆Stackable notifications with a dedicated viewport.
Notes
Important implementation details to consider.
Implementation Details
- ◆Install: Run'npx futureuikit add toast'to add the provider, hook, and component files.
- ◆Root Setup: Place the <Toaster /> component in your root'layout.tsx'within the <body>.
- ◆Triggering: Import the'useToast'hook and call'toast({...})'with'title'and'description'.
- ◆Variants: Set'variant: "destructive"'in the toast options for error messages.
- ◆Placement: Control the toast position via the <Toaster /> component props (e.g., top-right).