Alert
weekendsuperhero-io-sistine/alertUnverifiedComponent
Displays a callout for user attention with optional glass material.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/Weekendsuperhero-io/sistine/main/alert.jsonSource
1import { cva, type VariantProps } from "class-variance-authority";2import * as React from "react";34import { type HoverEffect, hoverEffects } from "@/lib/hover-effects";5import { type MaterialAxisProps, type MaterialProps, materialSurface, splitAxisProps } from "@/lib/material";6import { cn } from "@/lib/utils";78/* Variant classes carry BEHAVIOR only (text, status chrome); the surface comes from materialSurface.9 Status variants ride a BORDERLESS glass surface (their colored border is their own chrome). */10const alertVariants = cva(11 "relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",12 {13 variants: {14 variant: {15 default: "bg-background text-foreground",16 glass: "text-foreground",17 info: "border border-blue-500/60 text-blue-600 shadow-[var(--glass-shadow)] dark:text-blue-400 [&>svg]:text-blue-600 dark:[&>svg]:text-blue-400",18 success:19 "border border-green-500/60 text-green-600 shadow-[var(--glass-shadow)] dark:text-green-400 [&>svg]:text-green-600 dark:[&>svg]:text-green-400",20 warning:21 "border border-yellow-500/60 text-yellow-600 shadow-[var(--glass-shadow)] dark:text-yellow-400 [&>svg]:text-yellow-600 dark:[&>svg]:text-yellow-400",22 destructive: "border border-destructive/60 text-destructive shadow-[var(--glass-shadow)] [&>svg]:text-destructive",23 },24 },25 defaultVariants: {26 variant: "glass",27 },28 },29);3031const STATUS_VARIANTS = [32 "info",33 "success",34 "warning",35 "destructive",36] as const;3738/* Each semantic variant's surface role: statuses ride a BORDERLESS glass surface (their colored39 border is their own chrome); default renders no glass surface. */40const SURFACE_ROLE: Record<string, MaterialProps | null> = {41 default: null,42 glass: {},43 info: {},44 success: {},45 warning: {},46 destructive: {},47};4849const Alert = React.forwardRef<50 HTMLDivElement,51 React.HTMLAttributes<HTMLDivElement> &52 VariantProps<typeof alertVariants> &53 MaterialAxisProps & {54 effect?: HoverEffect;55 }56>(({ className, variant, effect, ...props }, ref) => {57 const [axes, rest] = splitAxisProps(props);58 const isStatus = variant !== null && variant !== undefined && (STATUS_VARIANTS as readonly string[]).includes(variant);59 const m = materialSurface(SURFACE_ROLE[variant ?? "glass"] ?? null, axes);6061 return (62 <div63 ref={ref}64// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from weekendsuperhero-io/sistine
All 71 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | weekendsuperhero-io/sistine | Components | Unverified | 5 deps · 4 files | |
| Alert Dialogalert-dialog | weekendsuperhero-io/sistine | Components | Unverified | 4 deps · 4 files | |
| Auto Foregroundauto-foreground | weekendsuperhero-io/sistine | Components | Unverified | no deps | |
| Avataravatar | weekendsuperhero-io/sistine | Components | Unverified | 4 deps · 4 files | |
| Badgebadge | weekendsuperhero-io/sistine | Components | Unverified | 4 deps · 4 files | |
| Breadcrumbbreadcrumb | weekendsuperhero-io/sistine | Components | Unverified | 5 deps · 4 files | |
| Buttonbutton | weekendsuperhero-io/sistine | Components | Unverified | 4 deps · 4 files | |
| Button Groupbutton-group | weekendsuperhero-io/sistine | Components | Unverified | 4 deps · 4 files |
