A semantic callout with five theme-aware tones, clear icon placement, an action row, and opt-in urgent announcements.
import { ShieldCheck } from "lucide-react"
import {
Alert,
AlertTitle,
AlertDescription,
AlertAction,
} from "@/components/ballmac/alert"
import { buttonVariants } from "@/components/ballmac/button"
export default function AlertDemo() {
return (
<Alert variant="success" className="max-w-md">
<ShieldCheck aria-hidden="true" />
<AlertTitle>Workspace is protected</AlertTitle>
<AlertDescription>
Two-factor authentication is active for every team member. Your security
review is complete.
</AlertDescription>
<AlertAction>
<a
href="#security"
className={buttonVariants({ variant: "outline", size: "sm" })}
>
Review settings
</a>
</AlertAction>
</Alert>
)
}Installation
$ pnpm dlx shadcn@latest add @ballmac/alertInstall the dependencies.
$ pnpm add class-variance-authorityCopy the source into your project.
components/ballmac/alert.tsx// Ballmac UI: Alert. https://ui.ballmac.com/components/alert // Based on shadcn/ui Alert (MIT, Copyright (c) 2023 shadcn), adding semantic tones and an action slot. import * as React from "react" import { cva, type VariantProps } from "class-variance-authority" import { cn } from "@/lib/utils" const alertVariants = cva( "grid w-full grid-cols-[auto_minmax(0,1fr)] items-start gap-x-3 gap-y-1 rounded-xl border p-4 text-sm [&>svg]:mt-0.5 [&>svg]:size-4", { variants: { variant: { default: "border-border bg-card text-card-foreground", info: "border-primary/25 bg-primary/5 text-foreground", success: "border-chart-2/30 bg-chart-2/10 text-foreground", warning: "border-chart-3/30 bg-chart-3/10 text-foreground", destructive: "border-destructive/30 bg-destructive/10 text-foreground", }, }, defaultVariants: { variant: "default" }, }, ) type AlertProps = React.ComponentProps<"div"> & VariantProps<typeof alertVariants> & { /** Announce urgent messages; ordinary alerts remain in the reading order. */ urgent?: boolean } function Alert({ className, variant = "default", urgent = false, ...props }: AlertProps) { return ( <div data-slot="alert" role={urgent ? "alert" : undefined} className={cn(alertVariants({ variant }), className)} {...props} /> ) } function AlertTitle({ className, ...props }: React.ComponentProps<"div">) { return ( <div data-slot="alert-title" className={cn("col-start-2 font-semibold leading-5", className)} {...props} /> ) } function AlertDescription({ className, ...props }: React.ComponentProps<"div">) { return ( <div data-slot="alert-description" className={cn( "col-start-2 text-muted-foreground leading-relaxed [&_p]:leading-relaxed", className, )} {...props} /> ) } function AlertAction({ className, ...props }: React.ComponentProps<"div">) { return ( <div data-slot="alert-action" className={cn( "col-start-2 mt-2 flex flex-wrap items-center gap-2", className, )} {...props} /> ) } export { Alert, AlertTitle, AlertDescription, AlertAction, alertVariants, type AlertProps, }Update the import paths to match your project setup.
Usage
import { Alert, AlertTitle, AlertDescription, AlertAction } from "@/components/ballmac/alert"The full example is in the Code tab above.
Examples
States and variants
import { CircleAlert, Info } from "lucide-react"
import { Alert, AlertTitle, AlertDescription } from "@/components/ballmac/alert"
export default function AlertStates() {
return (
<div className="flex w-full max-w-md flex-col gap-3">
<Alert variant="info">
<Info aria-hidden="true" />
<AlertTitle>Scheduled maintenance</AlertTitle>
<AlertDescription>
Reports will pause for ten minutes tonight.
</AlertDescription>
</Alert>
<Alert variant="warning">
<CircleAlert aria-hidden="true" />
<AlertTitle>Review needed</AlertTitle>
<AlertDescription>
One integration needs a new access token.
</AlertDescription>
</Alert>
</div>
)
}API reference
| Prop | Type | Default |
|---|---|---|
urgentAnnounce urgent messages; ordinary alerts remain in the reading order. | boolean | false |
variant | "default" | "info" | "success" | "warning" | "destructive" | "default" |
Also accepts the standard attributes of its root element.
Accessibility
| Key | Action |
|---|---|
| Tab | moves to links and actions |
Quality scorecard
Every applicable check passes
Measured in Chromium 153.0.8010.12 on October 19, 2026, on version 1.0.0, across 2 examples.
Passed: Accessibility scan
No serious or critical issues in light and dark, on a phone and a desktop (axe-core 4.13.0, WCAG 2.1 AA and best-practice rules).
Passed: Small screens
No sideways scrolling at 360, 390 or 1280 px wide.
Passed: Reduced motion
No endless animation to begin with.
Passed: Right to left
Mirrors correctly in Arabic, Hebrew, Persian and Urdu layouts (0% of elements off the mirror, limit 15%).
Passed: Clean console
No console errors or React hydration errors while loading.
Passed: Keyboard
1 tab stop, each showing a visible change when it takes focus. 1 documented key.
Not applicable: Loading, empty and error
Does not show data or take submissions.
For information: Automated tests
No test file of its own yet.
For information: Footprint
0.8 KB of source (gzip) in 1 file. Installs class-variance-authority.
Automated checks find a subset of problems and do not replace testing with a screen reader and a keyboard in your own app. What they miss.
Use with AI
A semantic callout with five theme-aware tones, clear icon placement, an action row, and opt-in urgent announcements. With the shadcn MCP server set up (guide), ask your agent:
Add the Ballmac UI Alert (@ballmac/alert) to this project with the shadcn MCP, then use it where it fits.
Use it for
- Display a status or important message
- Pair a warning with a clear next action
Not for
- Use a toast for transient confirmation
Registry JSON: https://ui.ballmac.com/r/alert.json
Credits
Based on shadcn/ui Alert, adapted by Ballmac. Free to use in personal and commercial projects.
- Registry
- shadcn/utils
Pairs well with
Badge
A small pill label in four variants with an optional status dot and success, warning and error tones. Style links with badgeVariants().
Button
A button with six variants, three sizes, a pill shape and a built-in loading state. buttonVariants() styles links the same way.
Alert Dialog
Focus-managed confirmation for consequential actions, with a clear cancel path, optional media, and a token-based destructive action.
Banner
A page-wide announcement with semantic tones, optional action, and controlled or local dismissal.
Ballmac UI Pro
Need the whole screen, not one piece?
311 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.
Not ready? Try three Pro blocks free
Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.