shadimage
afterglow
uialertsource: ok · hit

Alert

A notice with a lit left edge and a matching icon. Four tones.

npx shadcn add "https://afterglow.thebuilder.dk/r/alert.json"
free

No selection tags yet — empty means no evidence, not lack of support.

Dependencies

Bundle weight · light
class-variance-authority

Registry dependencies

@afterglow/theme

Files1 · source cached 10/8/2026, 6:48:40 PM

registry/terminal/ui/alert.tsx
import { cva } from "class-variance-authority";
import type { VariantProps } from "class-variance-authority";
import type * as React from "react";

import { cn } from "@/lib/utils";

const alertVariants = cva(
  "relative grid w-full grid-cols-[0_1fr] items-start gap-y-1 rounded-none border border-line border-l-2 bg-card/90 px-4 py-3 text-sm has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] has-[>svg]:gap-x-3 [&>svg]:size-4 [&>svg]:translate-y-0.5",
  {
    defaultVariants: { variant: "default" },
    variants: {
      variant: {
        default: "border-l-phosphor [&>svg]:text-phosphor",
        destructive:
          "border-l-destructive *:data-[slot=alert-title]:text-destructive *:data-[slot=alert-description]:text-destructive/80 [&>svg]:text-destructive",
        signal:
          "border-l-signal *:data-[slot=alert-title]:text-signal [&>svg]:text-signal",
        warn: "border-l-warning *:data-[slot=alert-title]:text-warning [&>svg]:text-warning",
      },
    },
  }
);

function Alert({
  className,
  variant,
  ...props
}: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {
  return (
    <div
      className={cn(alertVariants({ variant }), className)}
      data-slot="alert"
      role="alert"
      {...props}
    />
  );
}

function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {
  return (
    <div
      className={cn(
        "col-start-2 line-clamp-1 min-h-4 font-mono font-semibold text-1xs text-phosphor-bright uppercase tracking-terminal-lg",
        className
      )}
      data-slot="alert-title"
      {...props}
    />
  );
}

function AlertDescription({
  className,
  ...props
}: React.ComponentProps<"div">) {
  return (
    <div
      className={cn(
        "col-start-2 grid justify-items-start gap-1 text-muted-foreground text-sm [&_p]:leading-relaxed",
        className
      )}
      data-slot="alert-description"
      {...props}
    />
  );
}

export { Alert, AlertDescription, AlertTitle, alertVariants };

More from afterglow

Browse all components in this library →