Charcoal UI

Alert

Info, success, warning and error callouts that slide in and collapse smoothly when dismissed.

  • Category: Feedback
  • Licence: Free, MIT
  • Built with: React 19, Tailwind CSS 4, Motion
  • Dependencies: motion, clsx, tailwind-merge

Examples

Alert

API reference

PropTypeDefaultDescription
variant"info" | "success" | "warning" | "error""info"
titleReactNode—
actionReactNode—
dismissibleboolean—
onDismiss() => void—

About Alert

Alert is a set of info, success, warning and error callouts that slide in and collapse smoothly when dismissed, so the layout below moves instead of snapping.

Alert is a feedback component for React 19, styled with Tailwind CSS 4 and animated with Motion. It drops into Next.js, Vite, Remix or Astro through the shadcn CLI as a single file you own.

When to use Alert

  • Form errors and confirmations.
  • System and maintenance notices.
  • Inline tips in docs.
  • Billing and account warnings.

How it works

Height animates to zero on dismiss so content below glides up. Error and warning use the alert role so they are announced; info and success use status.

State changes are announced through live regions or the right ARIA roles, so screen-reader users hear what sighted users see. With prefers-reduced-motion on, it holds still or settles instantly instead of animating.

Customizing Alert

Every prop is documented in the API reference above with its type and default. The ones you will reach for first are listed here.

The Customize panel next to the preview lets you change variant, title, dismissible live, and the Code tab updates to match, so the snippet you copy already carries your values.

  • variant (default "info").
  • title (ReactNode).
  • action (ReactNode).
  • dismissible (boolean).

Goes well with Alert

These feedback pieces share its tokens and motion language, so they sit together on one page without clashing.

  • Progress: Animated React progress bars and rings on springs, with an indeterminate sweep
  • Loader: Four quiet React loaders, dots, bars, orbit and pulse, that announce themselves
  • Status Badge: A React status badge that morphs between states with a pulsing live dot
  • Skeleton: React skeleton loaders with a soft sweep and a blur crossfade to real content
  • Typing Indicator: A React typing indicator: a bubble with rippling dots that tells screen readers who is typing

Install Alert

npx shadcn@latest add https://charcoalui.com/r/alert.json

Alert is free and MIT licensed. The command copies alert.tsx into components/ui and installs clsx, tailwind-merge; you can also copy the source from the Code tab by hand.

It pairs well with Dynamic Island, a Pro piece: A black pill that morphs its size and content between states, like the iPhone's Dynamic Island.

Frequently asked questions

How do I install Alert?
Run npx shadcn@latest add https://charcoalui.com/r/alert.json. The shadcn CLI copies alert.tsx into components/ui and installs motion, clsx, tailwind-merge. You can also copy the source from this page by hand.
Is Alert free for commercial use?
Yes. Alert is MIT licensed: use it in any personal or commercial project and change it however you like.
Does Alert work with Next.js?
Yes. It is a client component for React 19 styled with Tailwind CSS 4, so it works in the Next.js App Router and Pages Router, Vite, Remix and Astro.
Can an AI coding agent install Alert?
Yes. Connect the Charcoal UI MCP server (https://charcoalui.com/mcp) to Claude Code, Cursor or any MCP client; get_component returns Alert's props and source and get_install_command returns the exact command.

Alert as Markdown · llms.txt