UIPin
ComponentsIconsIllustrationsMotionTemplatesApps
Boards
UIPin

Free, open-source UI components, icons, illustrations, motion, templates and apps, in one search. Every item links to its source and licence.

UIPin is free. If it saved you time, you can keep it running:

Buy me a coffee
ComponentsIconsIllustrationsMotionTemplatesAppsLibrariesCompareNew this weekMCP for agentsBoardsPrivacy

Components, icons and artwork belong to their authors and are shown under their open-source licences.

SmoothUI/Alert

Feedback & loaders
1 of 7
Compiling

Theme it

Every preview, live

Brand colour

Corner radius

Font

Recolours shadcn’s tokens, Tailwind’s accent colours and colours set in the code. Red, amber and green classes stay, since they usually mean error, warning or success.

7 versions·4 librariesCompare all alerts →

  • SmoothUI
  • 8-bit Alert
  • 8-bit Alert Dialog
  • Alert
  • Alert dialog
  • Alert
  • Alert Dialog

Alert

Inline Alert for SmoothUI — info, success, warning, and destructive banners.

npx shadcn@latest add https://smoothui.dev/r/alert.json
Open in v0 Docs Repo
Library
SmoothUI
License
MIT
Stack
React · Tailwind CSS
Size
79 lines

Code

components/smoothui/alert/index.tsx

"use client";

import { cn } from "@/lib/utils";
import type { ComponentProps, ReactNode } from "react";

export type AlertVariant = "info" | "success" | "warning" | "destructive";

export interface AlertProps extends Omit<ComponentProps<"div">, "title"> {
  /** Body copy under the title */
  children?: ReactNode;
  /** Optional leading icon */
  icon?: ReactNode;
  /** Bold heading line */
  title?: ReactNode;
  /** Semantic tone */
  variant?: AlertVariant;
}

const VARIANT_CLASS: Record<AlertVariant, string> = {
  destructive:
    "border-destructive/30 bg-destructive/10 text-destructive dark:border-destructive/40",
  info: "border-foreground/15 bg-foreground/5 text-foreground",
  success:
    "border-emerald-500/30 bg-emerald-500/10 text-emerald-800 dark:text-emerald-300",
  warning:
    "border-amber-500/30 bg-amber-500/10 text-amber-900 dark:text-amber-300",
};

/**
 * SmoothUI Alert — inline page/form notice (not a dialog). SmoothUI-owned.
 */
export default function Alert({
  children,
  className,
  icon,
  title,
  variant = "info",
  ...props
}: AlertProps) {
  return (
    <div
      className={cn(
        "relative flex w-full gap-3 rounded-lg border px-4 py-3 text-sm",
        VARIANT_CLASS[variant],
        className
      )}
      data-slot="alert"
      data-variant={variant}
      role="alert"
      {...props}
    >
      {icon ? (
        <span
          aria-hidden
          className="mt-0.5 shrink-0 [&_svg]:size-4"
          data-slot="alert-icon"
        >
          {icon}
        </span>
      ) : null}
      <div className="flex min-w-0 flex-1 flex-col gap-1">
        {title ? (
          <div className="font-medium leading-none" data-slot="alert-title">
            {title}
          </div>
        ) : null}
        {children ? (
          <div
            className="text-current/80 leading-relaxed [&_a]:underline"
            data-slot="alert-description"
          >
            {children}
          </div>
        ) : null}
      </div>
    </div>
  );
}

More like this

Ai Prompt Input

SmoothUI·Inputs & forms

Input

shadcn/ui·Inputs & forms

Textarea

shadcn/ui·Text effects

Accordion

SmoothUI·Data display

Marking Menu

Kokonut UI·Overlays

Dot Pattern

Magic UI·Backgrounds

Command

shadcn/ui·Overlays

Grid

Eldora UI·Other

Skeleton

shadcn/ui·Feedback & loaders

Sidebar

shadcn/ui·Navigation

Android

Magic UI·Media & 3D

Progress

shadcn/ui·Feedback & loaders

Progressive Blur

Magic UI·Feedback & loaders

Ai Message

SmoothUI·Backgrounds

Ai Reasoning

SmoothUI·Media & 3D