alert
amarjay-ui/alertFreeComponent
Callout component for important information or status.
Live preview
live · rendered by the registry
Rendered by amarjay-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://ui.amarjay.com/r/alert.jsonSource
1import * as React from "react"2import { cva, type VariantProps } from "class-variance-authority"34import { cn } from "@/lib/utils"56const alertVariants = cva(7 "group/alert relative grid w-full gap-0.5 rounded-lg border px-2 py-1.5 text-left text-xs/relaxed has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-1.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-3.5",8 {9 variants: {10 variant: {11 default: "bg-card text-card-foreground",12 destructive:13 "bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current",14 },15 },16 defaultVariants: {17 variant: "default",18 },19 }20)2122function Alert({23 className,24 variant,25 ...props26}: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>) {27 return (28 <div29 data-slot="alert"30 role="alert"31 className={cn(alertVariants({ variant }), className)}32 {...props}33 />34 )35}3637function AlertTitle({ className, ...props }: React.ComponentProps<"div">) {38 return (39 <div40 data-slot="alert-title"41 className={cn(42 "font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",43 className44 )}45 {...props}46 />47 )48}4950function AlertDescription({51 className,52 ...props53}: React.ComponentProps<"div">) {54 return (55 <div56 data-slot="alert-description"57 className={cn(58 "text-xs/relaxed text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",59 className60 )}61 {...props}62 />63 )64}6566function AlertAction({ className, ...props }: React.ComponentProps<"div">) {67 return (68 <div69 data-slot="alert-action"70 className={cn("absolute top-1.5 right-2", className)}71 {...props}72 />73 )74}7576export { Alert, AlertTitle, AlertDescription, AlertAction }
What it pulls in
npm packages
Other registry items
Files it writes
More from amarjay-ui
All 18 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| avataravatar | amarjay-ui | Components | Free | 1 dep | |
| badgebadge | amarjay-ui | Components | Free | 2 deps | |
| buttonbutton | amarjay-ui | Components | Free | 2 deps | |
| cardcard | amarjay-ui | Components | Free | no deps | |
| chartchart | amarjay-ui | Components | Free | 1 dep | |
| context-menucontext-menu | amarjay-ui | Components | Free | 2 deps | |
| dialogdialog | amarjay-ui | Components | Free | 2 deps | |
| dropdown-menudropdown-menu | amarjay-ui | Components | Free | 2 deps |
