Alert
uiable/alertFreeComponent
Alert component.
Live preview
live · rendered by the registry
Rendered by uiable on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://uiable.com/r/alert.jsonSource
1import { ComponentProps } from "react";23import { cva, type VariantProps } from "class-variance-authority";45import { cn } from "@/lib/utils";67const alertVariants = cva(8 "grid gap-0.5 rounded-lg border border-border px-5 py-3 text-left text-base has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4 w-full relative group/alert",9 {10 variants: {11 variant: {12 default: "bg-card text-card-foreground",13 destructive:14 "text-destructive bg-card *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current"15 }16 },17 defaultVariants: {18 variant: "default"19 }20 }21);2223function Alert({24 className,25 variant,26 ...props27}: ComponentProps<"div"> & VariantProps<typeof alertVariants>) {28 return (29 <div30 data-slot="alert"31 role="alert"32 className={cn(alertVariants({ variant }), className)}33 {...props}34 />35 );36}3738function AlertTitle({ className, ...props }: ComponentProps<"div">) {39 return (40 <div41 data-slot="alert-title"42 className={cn(43 "[&_a]:hover:text-foreground font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3",44 className45 )}46 {...props}47 />48 );49}5051function AlertDescription({52 className,53 ...props54}: ComponentProps<"div">) {55 return (56 <div57 data-slot="alert-description"58 className={cn(59 "[&_a]:hover:text-foreground text-base text-balance md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_p:not(:last-child)]:mb-4",60 className61 )}62 {...props}63 />64 );65}6667function AlertAction({ className, ...props }: ComponentProps<"div">) {68 return (69 <div70 data-slot="alert-action"71 className={cn("absolute top-3 right-3", className)}72 {...props}73 />74 );75}7677export { Alert, AlertTitle, AlertDescription, AlertAction };
What it pulls in
npm packages
Files it writes
More from uiable
All 712 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | uiable | Components | Free | 2 deps | |
| Alert Dialogalert-dialog | uiable | Components | Free | 1 dep | |
| Aspect Ratioaspect-ratio | uiable | Components | Free | no deps | |
| Attachmentattachment | uiable | Components | Free | 2 deps | |
| Avataravatar | uiable | Components | Free | 1 dep | |
| Badgebadge | uiable | Components | Free | 2 deps | |
| Breadcrumbbreadcrumb | uiable | Components | Free | 2 deps | |
| Bubblebubble | uiable | Components | Free | 2 deps |
