Inline alert
A compact info, success, warning or error message that sits within content.
npx shadcn@latest add https://ui.goodtabs.co/r/inline-alert.json
With the @goodtabs namespace in components.json: npx shadcn@latest add @goodtabs/inline-alert
Warning. Changes are saved as a draft until you publish.
A single warning with its label and message.
Tones
Info. Tokens sync from the design file every night.
Success. Your domain is verified and serving traffic.
Warning. This component is deprecated and will be removed in v3.
Error. The build failed on line 42 of button.tsx.
All four tones. Each differs by icon shape and label, so none relies on colour.
Usage
import { InlineAlert } from "@/components/ui/inline-alert"
<InlineAlert tone="error">The build failed on line 42.</InlineAlert>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| tone | "info" | "success" | "warning" | "error" | "info" | Picks the icon and the visible label. Warning and error use role=alert. |
| children | ReactNode | The message, one or two sentences. |
Source
inline-alert/inline-alert.tsx
import * as React from "react";
import { CircleAlertIcon, CircleCheckIcon, InfoIcon, TriangleAlertIcon } from "lucide-react";
import { cn } from "@/lib/utils";
type Tone = "info" | "success" | "warning" | "error";
type InlineAlertProps = Omit<React.ComponentProps<"div">, "title"> & {
/** Picks the icon and the visible label. */
tone?: Tone;
/** The message, one or two sentences. */
children: React.ReactNode;
};
const ICON = { info: InfoIcon, success: CircleCheckIcon, warning: TriangleAlertIcon, error: CircleAlertIcon } as const;
const LABEL = { info: "Info", success: "Success", warning: "Warning", error: "Error" } as const;
/**
* A compact alert that sits in the flow of content. State is shown three ways at once:
* an icon shape, a visible label and, for errors, the destructive token on the icon and rule.
*/
export function InlineAlert({ tone = "info", children, className, ...props }: InlineAlertProps) {
const Icon = ICON[tone];
const error = tone === "error";
return (
<div
role={error || tone === "warning" ? "alert" : "status"}
data-slot="inline-alert"
data-tone={tone}
className={cn(
"flex items-start gap-2.5 rounded-lg border border-l-2 bg-muted/50 py-2.5 pr-3 pl-3 text-sm",
error ? "border-l-destructive" : "border-l-foreground/40",
className,
)}
{...props}
>
<Icon aria-hidden="true" className={cn("mt-0.5 size-4 shrink-0", error && "text-destructive")} />
<p className="m-0 min-w-0 text-foreground/70">
<strong className="font-medium text-foreground">{LABEL[tone]}.</strong> {children}
</p>
</div>
);
}
For AI agents
Hand your agent this page, the markdown at /components/inline-alert/prompt.md, or the Copy AI prompt button above.
When to use
- A note about the section or form right next to it
- Deprecation, limits and validation summaries inside docs or settings
- Messages that should stay put rather than disappear
When not to use
- Page-wide state, use the alert banner
- A message with a title, body and action, use the notice card
- Confirmation of an action that already finished, use a toast
Agent notes
- Server component, no state and no dismiss; compose your own if you need one
- Each tone has a different icon and a visible label word, so meaning survives greyscale
- Only error uses --destructive, on the icon and the left rule; the other tones stay in foreground tones
- The label is part of the sentence ('Warning. ...'), so write the message to follow it