Skip to main content
FeedbackLevel 2

Alert

警示框

WebMobileDesktopDifficulty: Medium

A message that has to be taken seriously: something broke, something is at risk, and you need to act on it.

01

Live Demo

Actually clickable

Your cloud backup is full. Clear some space to keep backing up.

Notice it neither disappears on its own nor collapses — because the user has to deal with it.

What you just saw:The red line reading "Wrong password" under a failed form field, the yellow banner reading "Your card has expired" at the top of a checkout page — both are alerts.

02

What it actually is

An alert is the "you cannot ignore this" category. It can sit inline in the page or live inside a dialog (an alert dialog). What they share is that the user is normally expected to respond. Unlike a toast it does not disappear on its own.

alertwarningerror alertnoticealert bannerinline alert
03

Anatomy · What it's made of

  1. Container容器

    Tinted background + a matching left border

  2. Icon图标

    Chosen by severity: i / ! / ×

  3. Title标题

    One sentence naming the problem

  4. Description说明

    Optional, how to fix it

  5. Action操作

    Such as "Retry" or "Go to settings"

04

When to Use

When it fits, and when it doesn't
Alert usage recommendations
SituationUse it?
The user must act before anything can continue (an error, a risk)Yes
The blast radius is large (a whole account, a network outage)Yes
The information has to stay on screen and cannot auto-dismissYes
Reporting the success of a small actionNo
You only want to offer a tip on how to use somethingDepends

Red means "something is wrong". If you render an ordinary tip in red, users stay anxious about the entire interface.

Three alerts on one page and users will ignore every single one of them.

05

Similar Patterns

Don't mix these up
Full comparisonToast vs Snackbar vs AlertThe action is done and I want to acknowledge it. Which one?See the table
06

How to tell AI

Three levels of prompt

Add the component name and specifics

Add a red alert at the top of the form: "This email is already registered", a supporting line "Use a different email, or sign in to your existing account", and a "Sign in" button. It disappears automatically once the user corrects the field.

07

Don't just say this to AI

Bad → Better

Don't say this to AI

Pop up a warning when something goes wrong.

Say this instead

Add a role="alert" alert at the top of the form: light red background + 3px left border + ! icon + the title "This email is already registered" + a suggested fix + a "Sign in" button, focused on submit failure and removed automatically once the input is corrected.

08

Share this card

Social-ready

Turn this pattern into a 3:4 or 1:1 knowledge card and export it as PNG right in the browser. No backend needed.