alert
neobrutalism/alertFreeComponent
neobrutalism publishes no description for this item.
Live preview
live · rendered by the registry
Rendered by neobrutalism on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://neobrutalism.com/r/alert.jsonSource
1import * as React from "react"2import { cva, type VariantProps } from "class-variance-authority"34import { cn } from "@/lib/utils"56// CSS-grid layout (shadcn-style): drop an icon as a direct child and the alert7// auto-arranges into an icon column + a content column — no manual flex wrapper.8// `has-[>svg]` adds the icon column only when an icon is present. NeoBrutalist9// chrome: hard 2px border, square corners, hard offset shadow.10const alertVariants = cva(11 cn(12 "group/alert relative grid w-full grid-cols-[0_1fr] items-start gap-y-1 rounded border-2 px-4 py-3 text-left text-sm shadow-md",13 "has-[>svg]:grid-cols-[1.25rem_1fr] has-[>svg]:gap-x-3",14 "has-data-[slot=alert-action]:pr-14",15 "[&>svg]:size-5 [&>svg]:translate-y-0.5 [&>svg]:shrink-0 [&>svg]:text-current"16 ),17 {18 variants: {19 // shadcn's variant axis (kept for API compatibility). `solid` is a Neobrutalism20 // addition.21 variant: {22 default:23 "border-border bg-background text-foreground *:data-[slot=alert-description]:text-muted-foreground",24 destructive:25 "border-red-900 bg-red-300 text-red-900 *:data-[slot=alert-description]:text-red-900/80",26 solid:27 "border-border bg-foreground text-background *:data-[slot=alert-description]:text-background/80",28 },29 // Neobrutalism status axis — additive; overrides the variant's colors when set.30 status: {31 error:32 "border-red-900 bg-red-300 text-red-900 *:data-[slot=alert-description]:text-red-900/80",33 success:34 "border-green-900 bg-green-300 text-green-900 *:data-[slot=alert-description]:text-green-900/80",35 warning:36 "border-yellow-900 bg-yellow-300 text-yellow-900 *:data-[slot=alert-description]:text-yellow-900/80",37 info: "border-blue-900 bg-blue-300 text-blue-900 *:data-[slot=alert-description]:text-blue-900/80",38 },39 },40 defaultVariants: {41 variant: "default",42 },43 }44)4546function Alert({47 className,48 variant,49 status,50 ...props51}: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {52 return (53 <div54 data-slot="alert"55 role="alert"56 className={cn(alertVariants({ variant, status }), className)}57 {...props}58 />59 )60}6162function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {63 return (64 <div65 data-slot="alert-title"66 className={cn(67// … truncated
What it pulls in
npm packages
Files it writes
More from neobrutalism
All 54 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | neobrutalism | Components | Free | 2 deps | |
| alert-dialogalert-dialog | neobrutalism | Components | Free | 1 dep | |
| aspect-ratioaspect-ratio | neobrutalism | Components | Free | 1 dep | |
| avataravatar | neobrutalism | Components | Free | 1 dep | |
| badgebadge | neobrutalism | Components | Free | 2 deps | |
| breadcrumbbreadcrumb | neobrutalism | Components | Free | 2 deps | |
| buttonbutton | neobrutalism | Components | Free | 2 deps | |
| button-groupbutton-group | neobrutalism | Components | Free | 2 deps |
