alert
draco-china-github/alertFreeComponent
shadcn/ui publishes no description for this item.
Install it
npx shadcn@latest add https://raw.githubusercontent.com/draco-china/shadcn-pro/main/apps/docs/public/r/styles/radix-sera/alert.jsonSource
1import * as React from "react"2import { cva, type VariantProps } from "class-variance-authority"34import { cn } from "@/registry/radix-sera/lib/utils"56const alertVariants = cva(7 "group/alert relative grid w-full gap-1 border bg-background px-4 py-3 text-left text-sm after:absolute after:-inset-y-px after:-left-px after:w-0.5 has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2.5 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",8 {9 variants: {10 variant: {11 default: "bg-card text-card-foreground after:bg-foreground",12 destructive:13 "bg-card text-destructive after:bg-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 "text-sm font-semibold 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-sm 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-2.5 right-3", className)}71 {...props}72 />73 )74}7576export { Alert, AlertTitle, AlertDescription, AlertAction }
Files it writes
More from shadcn/ui
All 201 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| accordionaccordion | shadcn/ui | Components | Free | no deps | |
| alert-dialogalert-dialog | shadcn/ui | Components | Free | no deps | |
| aspect-ratioaspect-ratio | shadcn/ui | Components | Free | no deps | |
| avataravatar | shadcn/ui | Components | Free | no deps | |
| badgebadge | shadcn/ui | Components | Free | no deps | |
| breadcrumbbreadcrumb | shadcn/ui | Components | Free | no deps | |
| buttonbutton | shadcn/ui | Components | Free | no deps | |
| button-groupbutton-group | shadcn/ui | Components | Free | no deps |
