Alert
cubby-ui/alertFreeComponent
A alert component.
Live preview
live · rendered by the registry
Rendered by cubby-ui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://cubby-ui.dev/r/alert.jsonSource
1"use client";23import { cva, type VariantProps } from "class-variance-authority";4import { mergeProps } from "@base-ui/react/merge-props";5import { useRender } from "@base-ui/react/use-render";67import { cn } from "@/lib/utils";89const alertVariants = cva(10 "relative w-full rounded-lg border border-border/70 px-4 py-3 pl-6 text-sm grid has-[>svg]:grid-cols-[auto_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:row-span-2 [&>svg]:text-current shadow-sm has-[*[data-slot=alert-action]]:grid-cols-[0_1fr] has-[>svg]:has-[*[data-slot=alert-action]]:grid-cols-[auto_1fr] sm:has-[*[data-slot=alert-action]]:grid-cols-[0_1fr_auto] sm:has-[>svg]:has-[*[data-slot=alert-action]]:grid-cols-[auto_1fr_auto] [&>svg]:size-5 group before:absolute before:left-2 before:top-2 before:bottom-2 before:w-1 before:rounded-full bg-card dark:bg-muted",11 {12 variants: {13 variant: {14 default: "[&>svg]:text-card-foreground before:bg-border",15 warning:16 " [&>svg]:text-warning-foreground before:bg-warning-foreground",17 danger: " [&>svg]:text-danger-foreground before:bg-danger-foreground",18 info: " [&>svg]:text-info-foreground before:bg-info-foreground",19 success:20 " [&>svg]:text-success-foreground before:bg-success-foreground",21 },22 },23 defaultVariants: {24 variant: "default",25 },26 },27);2829export interface AlertProps30 extends useRender.ComponentProps<"div">, VariantProps<typeof alertVariants> {}3132function Alert({ className, variant, render, ...props }: AlertProps) {33 const defaultProps = {34 "data-slot": "alert",35 role: "alert" as const,36 className: cn(alertVariants({ variant }), className),37 };3839 const element = useRender({40 defaultTagName: "div",41 render,42 props: mergeProps<"div">(defaultProps, props),43 });4445 return element;46}4748export type AlertTitleProps = useRender.ComponentProps<"h4">;4950function AlertTitle({ className, render, ...props }: AlertTitleProps) {51 const defaultProps = {52 "data-slot": "alert-title",53 className: cn(54 "col-start-2 min-h-4 font-medium tracking-tight row-span-2 self-center group-has-[*[data-slot=alert-description]]:row-span-1 text-card-foreground",55 className,56 ),57 };5859 const element = useRender({60 defaultTagName: "h4",61 render,62 props: mergeProps<"h4">(defaultProps, props),63 });6465 return element;66}6768export type AlertDescriptionProps = useRender.ComponentProps<"div">;6970function AlertDescription({71// … truncated
What it pulls in
npm packages
Files it writes
More from cubby-ui
All 79 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordionaccordion | cubby-ui | Components | Free | 2 deps | |
| Alert-dialogalert-dialog | cubby-ui | Components | Free | 2 deps | |
| Aspect-ratioaspect-ratio | cubby-ui | Components | Free | no deps | |
| Autocompleteautocomplete | cubby-ui | Components | Free | 2 deps | |
| Avataravatar | cubby-ui | Components | Free | 1 dep | |
| Badgebadge | cubby-ui | Components | Free | 1 dep | |
| Base Drawerbase-drawer | cubby-ui | Components | Free | 2 deps | |
| Breadcrumbsbreadcrumbs | cubby-ui | Components | Free | 2 deps |
