Sean Hello

Custom Invert Error Toast

Component 6

About

A dark, inverted toast notification for a failed build that shows an error summary, file-level stack details, and View Logs / Retry actions.

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

Code

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

Usage.tsx

import { useEffect } from "react";
import { toast, Toaster as SonnerToaster } from "sonner";
import { XIcon } from "lucide-react";

import { Button } from "@/components/ui/c-sonner-14-utils/button";
import { Separator } from "@/components/ui/separator";

function CustomInvertErrorToast() {
  const showToast = () => {
    toast.custom(
      () => (
        <div className="bg-invert text-invert-foreground rounded-md flex w-[356px] flex-col gap-3 border border-transparent p-4 shadow-lg">
          <div className="flex items-start gap-3">
            <div className="flex size-6 shrink-0 items-center justify-center rounded-full bg-red-500 text-white">
              <XIcon className="size-3.5" />
            </div>
            <div className="flex flex-1 flex-col gap-1">
              <p className="text-sm font-semibold">Build Failed</p>
              <p className="text-invert-foreground/70 text-sm">
                Compilation error in 2 files. Fix errors before deploying.
              </p>
            </div>
          </div>
          <Separator className="bg-border/10" />
          <div className="text-invert-foreground/60 space-y-1 font-mono text-xs">
            <p>src/api/auth.ts:42 — TypeError: undefined is not a function</p>
            <p>src/utils/parse.ts:18 — SyntaxError: Unexpected token</p>
          </div>
          <div className="flex gap-2">
            <Button
              size="xs"
              variant="outline"
              className="bg-background/10 border-border/10 text-invert-foreground flex-1"
              onClick={() => toast.dismiss()}
            >
              View Logs
            </Button>
            <Button
              size="xs"
              className="flex-1 border-red-800 bg-red-500 text-white hover:border-red-900 hover:bg-red-600"
              onClick={() => toast.dismiss()}
            >
              Retry Build
            </Button>
          </div>
        </div>
      ),
      { duration: Infinity },
    );
  };

  return (
    <div className="flex items-center justify-center">
      <Button onClick={showToast} variant="outline" className="w-fit">
        Invert Error Toast
      </Button>
    </div>
  );
}

export default function CustomInvertErrorToastDemo() {
  return (
    <div className="flex min-h-[400px] w-full items-center justify-center">
      <CustomInvertErrorToast />
      <SonnerToaster position="top-center" />
    </div>
  );
}

Dependencies

More by Sean Hello

View all
  • 3D Testimonails

    3D Testimonails

    3.3K
  • Line Charts 9

    Line Charts 9

    632
  • Alert

    Alert

    492
  • Area Charts 1

    Area Charts 1

    384
  • Line Charts 6

    Line Charts 6

    382
  • Scroll Area

    Scroll Area

    376
  • Area Charts 2

    Area Charts 2

    316
  • Navigation Menu

    Navigation Menu

    305