dixant

Toast Notification

Component

About

A dismissible toast notification system with a provider and hook for firing success, error, warning, or info messages from anywhere in the app.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Toast Notification to your project and fits it to your theme.

Code

How Toast Notification is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { ToastProvider, useToast } from "@/components/ui/toast";
import { Button } from "@/components/ui/toast-utils/Button";

function Fire({
  variant = "info",
  title,
  description,
  duration,
  action,
}: {
  variant?: "success" | "error" | "warning" | "info";
  title?: string;
  description?: string;
  duration?: number;
  action?: { label: string; onClick: () => void };
}) {
  const { toast } = useToast();
  return (
    <Button
      variant={variant === "error" ? "destructive" : "primary"}
      onClick={() =>
        toast({
          title: title ?? `${variant} toast`,
          description,
          variant,
          duration,
          action,
        })
      }
    >
      Fire {variant}
    </Button>
  );
}

export default function ToastDemo() {
  return (
    <ToastProvider>
      <div style={{ display: "flex", gap: 8, flexWrap: "wrap" }}>
        <Fire
          variant="success"
          title="Saved"
          description="Your changes are safe."
        />
        <Fire
          variant="error"
          title="Failed"
          description="Something went wrong."
        />
        <Fire variant="warning" title="Careful" description="Low disk space." />
        <Fire
          variant="info"
          title="Heads up"
          description="New version available."
        />
      </div>
    </ToastProvider>
  );
}

More by dixant

View all
  • Tooltip

    Tooltip

    1
  • Select

    Select

  • Tatva Input

    Tatva Input

  • Typography

    Typography

  • Avatar

    Avatar

  • Divider

    Divider

  • Stack

    Stack

  • Alert

    Alert