Docs
Toast

Toast

A succinct message that is displayed temporarily.

Simple

With title

With Action

Destructive

Use toast({ variant: "destructive" }) to display a destructive toast.

Installation

Install the following dependencies:

npm install @radix-ui/react-toast

Copy and paste the following code into your project.

toast.tsx

toaster.tsx

use-toast.tsx

Copy and paste the toast code into your project.

Add the Toaster component

app/layout.tsx
import { Toaster } from "@/components/ui/toaster"
 
export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <head />
      <body>
        <main>{children}</main>
        <Toaster />
      </body>
    </html>
  )
}