Toast

A succinct message that is displayed temporarily.

toast
Description of the SVG image Loading...

Variants

Description of the SVG image Loading...

Installation

Run the following command:

npx ever-ui-clx@0.2.1 add demo-toast
npx ever-ui-clx@0.2.1 add toaster
npx ever-ui-clx@0.2.1 add hooks/use-has-focus
npx ever-ui-clx@0.2.1 add hooks/use-media-query

Modify your tailwind.config.ts as follows:

// tailwind.config.ts
module.exports = {
  theme: {
    extend: {
      colors: {
        success: {
          DEFAULT: "hsl(var(--success))",
          foreground: "hsl(var(--success-foreground))",
        },
        warning: {
          DEFAULT: "hsl(var(--warning))",
          foreground: "hsl(var(--warning-foreground))",
        },
        error: {
          DEFAULT: "hsl(var(--error))",
          foreground: "hsl(var(--error-foreground))",
        },
      },
      keyframes: {
        "track-toast-duration": {
          "0%": { transform: "scaleX(1)" },
          "100%": { transform: "scaleX(0)" },
        },
      },
      animation: {
        "track-toast-duration": "track-toast-duration ease-in-out forwards",
      },
    },
  },
};

Modify your globals.css as follows:

--success: 81 37% 44%;
--success-foreground: 71 44% 95%;
--warning: 32 95% 44%;
--warning-foreground: 48 100% 96%;
--error: 14 100% 53%;
--error-foreground: 0 86% 97%;

Add the Toaster component in your app/layout.tsx file:

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

Usage