Alert
boldkit/alertFreeComponent
Displays a callout for user attention with bold neubrutalism borders
Live preview
live · rendered by the registry
Rendered by boldkit on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://boldkit.dev/r/alert.jsonSource
1import * as React from 'react'2import { cva, type VariantProps } from 'class-variance-authority'3import { cn } from '@/lib/utils'45const alertVariants = cva(6 'relative w-full border-3 border-foreground p-4 shadow-[4px_4px_0px_hsl(var(--shadow-color))] ease-out animate-in fade-in-0 slide-in-from-top-2 duration-300 transition [&>svg~*:not([data-alert-action])]:pl-8 [&>svg~[data-alert-action]]:ml-8 [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground',7 {8 variants: {9 variant: {10 default: 'bg-background text-foreground',11 destructive: 'bg-destructive text-destructive-foreground [&>svg]:text-destructive-foreground',12 success: 'bg-success text-success-foreground',13 warning: 'bg-warning text-warning-foreground',14 info: 'bg-info text-info-foreground',15 },16 },17 defaultVariants: {18 variant: 'default',19 },20 }21)2223const Alert = React.forwardRef<24 HTMLDivElement,25 React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>26>(({ className, variant, ...props }, ref) => (27 <div28 ref={ref}29 role="alert"30 className={cn(alertVariants({ variant }), className)}31 {...props}32 />33))34Alert.displayName = 'Alert'3536const AlertTitle = React.forwardRef<37 HTMLHeadingElement,38 React.HTMLAttributes<HTMLHeadingElement>39>(({ className, ...props }, ref) => (40 <h541 ref={ref}42 className={cn('mb-1 font-bold uppercase tracking-wide leading-none', className)}43 {...props}44 />45))46AlertTitle.displayName = 'AlertTitle'4748const AlertDescription = React.forwardRef<49 HTMLParagraphElement,50 React.HTMLAttributes<HTMLParagraphElement>51>(({ className, ...props }, ref) => (52 <div53 ref={ref}54 className={cn('text-sm [&_p]:leading-relaxed', className)}55 {...props}56 />57))58AlertDescription.displayName = 'AlertDescription'5960export interface AlertActionProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {61 /** Shows an inline spinner and disables the button automatically */62 loading?: boolean63}6465const AlertAction = React.forwardRef<HTMLButtonElement, AlertActionProps>(66 ({ className, loading, disabled, children, ...props }, ref) => (67 <button68 ref={ref}69 data-alert-action=""70 disabled={disabled || loading}71 className={cn(72 // layout73 'mt-3 inline-flex items-center gap-1.5 max-w-full min-w-0',74 // shape — no rounded corners, thin border inheriting text color75// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from boldkit
All 94 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | boldkit | Components | Free | 2 deps | |
| Alert Dialogalert-dialog | boldkit | Components | Free | 1 dep | |
| ASCII Shapesascii-shapes | boldkit | Components | Free | no deps | |
| Aspect Ratioaspect-ratio | boldkit | Components | Free | 1 dep | |
| Avataravatar | boldkit | Components | Free | 1 dep | |
| Badgebadge | boldkit | Components | Free | 1 dep | |
| Breadcrumbbreadcrumb | boldkit | Components | Free | 2 deps | |
| Buttonbutton | boldkit | Components | Free | 2 deps |
