Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Error with Title Alert for Ark UI

A destructive alert that shows only the word Error. No icon, no description, and no button, when the failure needs no extra line.

One line, the word Error, on a destructive alert. No icon, no description, and no button.

Use it when the failure is already obvious beside the form. If the cause is one input, mark that Field. In React, Ark UI does not add a close control.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Use email insteadNo credit card

Anatomy

Alert anatomy: root, icon, title, description, action

Usage

<Alert className="max-w-lg" variant="destructive">
  <AlertTitle>Error</AlertTitle>
</Alert>

FAQ

When should I use a title-only error alert?

When one line is the whole message. This demo is an Alert with variant="destructive" and a single AlertTitle. Add AlertDescription when the reader still needs the reason or the next step.

Where do the error colors come from?

From variant="destructive": the alert takes the theme's destructive color for its text and icon, so it follows light and dark mode and any theme you install. There are no color classes in the demo; change the --destructive token to restyle every destructive alert at once.

What does the title render as?

AlertTitle is a div with the text Error. It is font-medium and inherits the destructive text color. className="max-w-lg" on Alert caps the width.

Should error alerts be dismissible?

Usually not: an error should stay until its cause is fixed, then go away because your code stops rendering it. The Alert has no built-in close button. If you want one, keep its visibility in your own state and put a button in AlertAction that hides it.

How do I add an icon to this alert?

Put an svg first, before AlertTitle. The alert then adds an icon column, spans the icon across the rows, and sizes an unsized icon. This demo leaves the icon out, so that column is not there.

Are error alerts accessible to screen readers?

Yes. Alert renders with role="alert", so a screen reader announces the title as soon as the alert appears. The color is not the only signal, since the title names the problem in text.

API Reference

Alert

Sets variant="destructive". The rest is on the Alert page.