Alert (Tailwind)
roi-ui/alert-tailwindFreeItem
A component for displaying important messages to users.
Install it
npx shadcn@latest add https://roiui.com/r/alert-tailwind.jsonSource
1import { cva, type VariantProps } from "class-variance-authority";2import type { ReactNode } from "react";3import { cn } from "@/lib/utils";45const alertVariants = cva(6 [7 "relative mt-6 w-full rounded-2xl",8 "grid grid-cols-[1fr_auto] items-start gap-y-0.5 px-5 py-4",9 "bg-card text-xs leading-[1.2]",10 "border border-[var(--border)]",11 "max-sm:gap-y-2 max-sm:px-3",12 ],13 {14 variants: {15 variant: {16 default: "[--alert-accent:var(--muted-foreground)]",17 destructive: "[--alert-accent:var(--destructive)]",18 warning: "[--alert-accent:var(--warning-foreground)]",19 success: "[--alert-accent:var(--success)]",20 info: "[--alert-accent:var(--info)]",21 },22 },23 defaultVariants: {24 variant: "default",25 },26 }27);2829function DefaultAlertIcon() {30 return (31 <svg32 aria-hidden="true"33 fill="none"34 height="16"35 stroke="currentColor"36 strokeLinecap="round"37 strokeLinejoin="round"38 strokeWidth="2"39 viewBox="0 0 24 24"40 width="16"41 xmlns="http://www.w3.org/2000/svg"42 >43 <circle cx="12" cy="12" r="10" />44 <path d="M12 16V11.5" />45 <path d="M12 8.01172V8.00172" />46 </svg>47 );48}4950interface AlertProps extends React.ComponentProps<"div">, VariantProps<typeof alertVariants> {51 icon?: ReactNode;52}5354function Alert({ className, variant, icon, children, ...props }: AlertProps) {55 const filteredChildren = Array.isArray(children)56 ? children.filter((child) => !(child && typeof child === "object" && "type" in child && child.type === "svg"))57 : children;5859 return (60 <div className={cn(alertVariants({ variant }), className)} data-slot="alert" role="alert" {...props}>61 <div className="-inset-px pointer-events-none absolute rounded-[inherit] shadow-[var(--shadow-ring)]" />62 <div className="-top-[13px] pointer-events-none absolute left-[15px] h-[26px] w-[26px] rounded-full bg-[var(--background)]" />63 <div64 className="-top-[13px] pointer-events-none absolute left-[15px] h-[26px] w-[26px] rounded-full shadow-[0_0_0_1px_var(--border)]"65 style={{ clipPath: "inset(50% -3px -3px -3px)" }}66 />67 <div className="-top-[7px] pointer-events-none absolute left-[20px] flex h-4 w-4 items-center justify-center text-[color:var(--alert-accent)] [&_svg]:h-4 [&_svg]:w-4">68 {icon ?? <DefaultAlertIcon />}69 </div>70 {filteredChildren}71 </div>72 );73}7475// … truncated
What it pulls in
npm packages
Files it writes
More from Roi UI
All 123 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | Roi UI | Other | Free | no deps · 2 files | |
| Accordion (Tailwind)accordion-tailwind | Roi UI | Other | Free | no deps | |
| AI Chatai-chat | Roi UI | Other | Free | no deps · 2 files | |
| AI Chat (Tailwind)ai-chat-tailwind | Roi UI | Other | Free | no deps | |
| Alertalert | Roi UI | Other | Free | 1 dep · 2 files | |
| Alert Dialogalert-dialog | Roi UI | Other | Free | no deps · 2 files | |
| Alert Dialog (Tailwind)alert-dialog-tailwind | Roi UI | Other | Free | no deps | |
| Autocompleteautocomplete | Roi UI | Other | Free | no deps · 2 files |
