Notification

Special

Toast notification system with auto-dismiss, stacking, variants, and action buttons.

Import

import { PixelNotification, usePixelToast } from "@/components/ui/pixel/pixel-notification"

Usage

✓

Success!

Your changes have been saved successfully.

⚠

Warning!

This action requires your attention.

✕

Error!

Something went wrong. Please try again.

Component Source

Copy and paste the following code into your project at /src/components/ui/pixel/pixel-notification.tsx

"use client";

import { cva, type VariantProps } from "class-variance-authority";
import * as React from "react";

const notificationVariants = cva(
  "relative border-4 border-black p-4 shadow-[6px_6px_0px_0px_rgba(0,0,0,1)] font-pixel flex items-start gap-3 min-w-[280px] max-w-[420px]",
  {
    variants: {
      variant: {
        default: "bg-white dark:bg-[#2a2a2a]",
        success: "bg-pixel-success border-black",
        warning: "bg-pixel-warning border-black",
        error: "bg-pixel-error border-black",
        info: "bg-pixel-primary border-black",
      },
      position: {
        "top-left": "animate-slide-in-left",
        "top-right": "animate-slide-in-right",
        "bottom-left": "animate-slide-in-left",
        "bottom-right": "animate-slide-in-right",
      },
    },
    defaultVariants: {
      variant: "default",
      position: "top-right",
    },
  },
);

export interface NotificationType {
  id: string;
  title: string;
  description?: string;
  variant?: "default" | "success" | "warning" | "error" | "info";
  icon?: React.ReactNode;
  duration?: number;
  action?: {
    label: string;
    onClick: () => void;
  };
}

interface PixelNotificationProps
  extends VariantProps<typeof notificationVariants> {
  title: string;
  description?: string;
  icon?: React.ReactNode;
  onClose?: () => void;
  action?: {

// ... (more code below)

Props

PropTypeDefaultDescription
titlestring-Notification title
descriptionstring-Notification message
variant"default" | "success" | "warning" | "error" | "info""default"Notification style
iconReactNode-Icon element
onClose() => void-Close callback
action{ label: string, onClick: () => void }-Action button config
durationnumber5000Auto-dismiss duration (ms), 0 for persistent

Examples

Success Toast

Success notification

✓

Success!

Your changes have been saved successfully.

⚠

Warning!

This action requires your attention.

✕

Error!

Something went wrong. Please try again.

With Action

Notification with action button

✓

Success!

Your changes have been saved successfully.

⚠

Warning!

This action requires your attention.

✕

Error!

Something went wrong. Please try again.

Toast Hook

Programmatic toast creation

✓

Success!

Your changes have been saved successfully.

⚠

Warning!

This action requires your attention.

✕

Error!

Something went wrong. Please try again.

Accessibility

This component is built with accessibility in mind, including proper ARIA attributes, keyboard navigation, and focus management.