BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/shadcn/alert

alert

shadcn/alert
FreeComponent

shadcn publishes no description for this item.

Live preview

live · rendered by the registry
Rendered by shadcn on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add alert

Source

ui/alert.tsxui.shadcn.com/r/styles/new-york/alert.json
1import * as React from "react"
2import { cva, type VariantProps } from "class-variance-authority"
3
4import { cn } from "@/lib/utils"
5
6const alertVariants = cva(
7 "relative w-full rounded-lg border px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-foreground [&>svg~*]:pl-7",
8 {
9 variants: {
10 variant: {
11 default: "bg-background text-foreground",
12 destructive:
13 "border-destructive/50 text-destructive dark:border-destructive [&>svg]:text-destructive",
14 },
15 },
16 defaultVariants: {
17 variant: "default",
18 },
19 }
20)
21
22const Alert = React.forwardRef<
23 HTMLDivElement,
24 React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
25>(({ className, variant, ...props }, ref) => (
26 <div
27 ref={ref}
28 role="alert"
29 className={cn(alertVariants({ variant }), className)}
30 {...props}
31 />
32))
33Alert.displayName = "Alert"
34
35const AlertTitle = React.forwardRef<
36 HTMLParagraphElement,
37 React.HTMLAttributes<HTMLHeadingElement>
38>(({ className, ...props }, ref) => (
39 <h5
40 ref={ref}
41 className={cn("mb-1 font-medium leading-none tracking-tight", className)}
42 {...props}
43 />
44))
45AlertTitle.displayName = "AlertTitle"
46
47const AlertDescription = React.forwardRef<
48 HTMLParagraphElement,
49 React.HTMLAttributes<HTMLParagraphElement>
50>(({ className, ...props }, ref) => (
51 <div
52 ref={ref}
53 className={cn("text-sm [&_p]:leading-relaxed", className)}
54 {...props}
55 />
56))
57AlertDescription.displayName = "AlertDescription"
58
59export { Alert, AlertTitle, AlertDescription }

Files it writes

  • ui/alert.tsx

Facts

Registry
shadcn
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-01
Last confirmed
yesterday

Go to the source

Docs on shadcn ui.shadcn.com shadcn-ui/ui on GitHub Raw registry item This item as JSON

More from shadcn

All 62 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
accordionaccordionshadcnComponentsFreeno deps
alert-dialogalert-dialogshadcnComponentsFreeno deps
aspect-ratioaspect-ratioshadcnComponentsFreeno deps
attachmentattachmentshadcnComponentsFreeno deps
avataravatarshadcnComponentsFreeno deps
badgebadgeshadcnComponentsFreeno deps
breadcrumbbreadcrumbshadcnComponentsFreeno deps
bubblebubbleshadcnComponentsFreeno deps
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex