AI 警示条生成器。

描述消息内容,MeDo 生成完整的内嵌警示条组合 — 信息、成功、警告、错误四种变体,配强调色条、图标、标题、说明文字、可选操作链接,以及当警示条不需要长期驻留时的关闭控件。

警示条
警示条

严重程度必须脱离颜色也能传达

警示条是唯一一个全部职责就是传达"事情有多严重"的组件,而颜色恰恰是完成这件事最不可靠的通道。大约每十二名男性中就有一人存在某种色觉缺陷,红与绿是最常被混淆的一对,同一个警示条在深色主题下、在亮度偏暗的笔记本屏幕上、或在灰度打印中,级别差异会完全消失。实际结论是:警示条从设计之初就需要冗余编码 — 每个级别配一个形状不同的图标,文案直接说明状况,而不是指望读者从色调里推断。把四种级别放在一次描述里生成,正是保证图标集真正可区分的方式,因为它们是彼此对照着挑选的,而不是一个一个单独定的。

6 个模板

可以生成的 警示条 模板

每个模板都是真实的提示词,而不是截图。复制到任意 AI 编辑器,或在 MeDo 中运行,直接拿到 React + Tailwind 代码。

BasicFour Severities

Accent-Bar Alert in Four Tones

The baseline set. Generating all four together is what keeps the icon shapes distinguishable from each other rather than four recolors of one glyph.

Create an inline alert component with four severities — info in blue with a circle icon, success in green with a check, warning in amber with a triangle, error in red with an octagon. Each is full width within its container with a 4px left accent bar in the severity color, a background tinted to roughly 8% of that color, 16px padding, an 8px radius, and a 20px icon aligned to the first text line rather than vertically centered. Render a semibold 15px title with an optional 14px muted description below. Because the alert renders with the page rather than appearing dynamically, use role="region" with an aria-label naming the severity, not role="alert" — an assertive live region on initial paint talks over everything else. Check every tinted background against its text color for 4.5:1 contrast.

在 MeDo 中尝试
ClosableDismissible

Alert With an Opt-In Close Button

Dismissal has to be per-instance, not global. A close button on an expired-payment alert lets the user hide a problem that still exists, and they will.

Add an opt-in dismiss control to an inline alert: a 32px icon button on the right with aria-label="Dismiss" and a visible focus ring, rendered only when a dismissible prop is passed so permanent alerts cannot be closed by accident. On dismiss, remove the alert from the DOM and move focus to the next focusable element after it rather than leaving focus on a detached node. Animate the collapse with height and opacity over 150ms, and skip the animation entirely under prefers-reduced-motion. Accept an onDismiss callback so the caller can persist the dismissal, and document that the alert should reappear on the next session while the underlying condition is unresolved.

在 MeDo 中尝试
With actionActionable

Alert Carrying One Next Step

An alert that names a problem without a route out of it just relocates the work. One action, concretely worded — two actions and neither reads as the primary.

Create an alert variant with a single inline action below the description, rendered in the severity color as a text link with an underline on hover and focus. Keep it to exactly one action so the next step is unambiguous, and require concrete wording in the label — "Update payment method", not "Learn more". If the action navigates, use an anchor; if it mutates state, use a button, and show an inline pending state on the button rather than replacing the alert while the request is in flight. Place the action inside the alert region so its purpose is announced together with the message, and keep its hit area at least 44px tall on touch.

在 MeDo 中尝试
CompactField Error

Single-Line Error Under an Input

No title, no icon block, no accent bar — just the message wired to the input it belongs to. The full alert anatomy next to a text field is visual noise that pushes the form apart.

Create a compact single-line alert for form-field errors: 13px text in the error color with a 14px inline icon, no title, no accent bar and no background tint, sitting 6px below its input with no vertical margin collapse. Give it a stable ID and reference it from the input with aria-describedby, and set aria-invalid="true" on the input at the same time. Because the message appears in response to a submit attempt, wrap it in role="alert" so it is announced immediately — but render the element only when there is an error rather than keeping an empty live region in the DOM, or the first error will be announced as a change to existing content. Reserve the line height so the layout does not jump when the message appears.

在 MeDo 中尝试
GlobalPage Banner

Full-Width Banner Above the App Shell

Trial countdowns, maintenance windows, degraded service. It sits above the layout rather than inside a page, so the thing that breaks is sticky-header offset math, not the alert itself.

Create a full-width alert banner that mounts above the application shell: edge-to-edge tinted background, centered content capped at the app container width, a 16px icon, one line of text and a single inline action, at 44px total height. Because it displaces the layout, expose its height as a CSS custom property on the root element so a sticky header can offset itself instead of being covered. Support a dismissible mode that persists to localStorage keyed by banner ID and version, so editing the message re-shows it to users who dismissed the previous one. Use role="region" with an aria-label rather than role="alert", since the banner is present on load and should not interrupt.

在 MeDo 中尝试
ValidationError Summary

Alert Listing Every Failed Field

The summary above the submit button, with one link per failure jumping to its input. It tells the user how many problems exist — the field-level messages tell them what to fix.

Create a validation summary alert for the top of a form: an error-severity block with a title stating the count — "3 fields need attention" — and an unordered list of links, each labelled with the field name plus the specific problem, each jumping to and focusing its input on click. Render it only after a submit attempt fails, give it role="alert" and move keyboard focus to the alert container itself with tabindex="-1" so a screen reader user lands on the summary rather than hunting for it. Rebuild the list on every failed submit and re-announce even when the set of errors is unchanged. Pair it with per-field messages wired through aria-describedby rather than replacing them.

在 MeDo 中尝试

如何自定义你的 警示条

给每种颜色配一个形状不同的图标

为每个级别指定具体图标 — 成功用对勾、警告用三角、错误用八边形、信息用圆圈。形状在灰度环境和色盲用户眼中依然可读,也让人在读到文字之前就能用余光判断严重程度。

提前决定警示条能否关闭

给描述未解决状况(例如支付方式已过期)的警示条加关闭按钮,等于让用户把仍然存在的问题藏起来。把关闭做成按实例选择开启,当消息只应在底层状态改变后才消失时,就让警示条长期驻留。

区分页面级横幅与字段级错误

页面级警示条是汇总信息,放在表单顶部;字段级错误紧贴在对应输入框下方,并通过 aria-describedby 关联。字段场景请要求紧凑单行变体,这样它就不会在文本输入框旁边带上标题和图标块。

把行动写进警示条

只描述问题却不给出路的警示条,只是把工作转移了位置。指定一个措辞具体的内嵌操作链接,例如"更新支付方式",并只保留一个操作,让下一步始终清晰。

谁在使用 警示条 组件

SaaS 产品

试用期剩三天时在应用顶部横跨整屏的长期驻留警告横幅,带"升级"操作链接;设置页内则用成功警示条确认配置已保存。

电商店铺

购物车页面用信息警示条说明发货截止时间,结账表单上方用错误警示条汇总支付被拒的详情,让消息在页面重新渲染后依然存在。

仪表盘或后台工具

数据导入界面用错误警示条列出哪些行未通过校验;计划维护时间窗则用信息警示条说明,并在时间窗结束前一直可见。

文档站点

内嵌提示型警示条把废弃 API 标为警告、把版本相关行为标为信息,直接放在正文流中 — 而浮动通知在这里毫无用处。

不同网站的 警示条 方案

同一个 警示条 组件,针对它所在网站的类型做调整。

01 / 06

SaaS Product Alerts

Trial countdowns and plan limits as permanent banners above the app shell, success alerts inside settings pages after a save. The banner is the tricky one: expose its height as a custom property or your sticky header will sit under it on every route.

警示条 的风格与变体

挑选与页面其余部分匹配的变体,然后生成它。

01 / 06

Left Accent Bar Alert

A 4px bar in the severity color with a tinted fill. The bar gives the eye a vertical edge to scan a stack of alerts against, which matters when three appear together on a settings page — four flat tinted boxes are much harder to separate.

在 React、Next.js、Vue 与 Svelte 中使用 警示条

React、Next.js、Vue 3、SvelteKit、Astro 或纯 HTML —— 同一个 警示条,六种接入方式。

01 / 06

React Alert

A static alert needs no state at all — keep the severity map outside the component so tones and icons stay in one place. Only the dismissible variant needs a hook, so split it out rather than making every alert stateful.

src/components/Alert.tsx

const tones = {
  info: { bar: 'bg-blue-500', bg: 'bg-blue-50', Icon: InfoIcon },
  error: { bar: 'bg-red-500', bg: 'bg-red-50', Icon: OctagonIcon },
}

export function Alert({ severity = 'info', title, children }) {
  const { bar, bg, Icon } = tones[severity]
  return (
    <div role="region" aria-label={severity} className={`flex gap-3 ${bg}`}>
      <span className={`w-1 ${bar}`} />
      <Icon className="mt-0.5 h-5 w-5" />
      <div>
        <p className="font-semibold">{title}</p>
        {children}
      </div>
    </div>
  )
}

如何把 警示条 加入项目

四个步骤,从挑选 警示条 模板到上线生产环境。

01~30s

Pick an Alert Pattern

Choose by where the message lives: the four-severity block for in-page state, the compact variant for a field error, the summary for a failed submit, the banner for something app-wide.

02~10s

Copy the Prompt

Take it into MeDo, Lovable, Bolt, v0 or Cursor. Decide whether this alert is dismissible before you run it — that choice determines whether a user can hide an unresolved problem.

03~1min

Generate and Refine

You get all four severities back with a live preview. Follow up in plain English — "add an Update payment method link", "make the error variant outlined", "drop the title on the compact one" — rather than recoloring tints by hand.

04~2min

Place It and Check the Roles

Put page-level alerts above the submit area and field errors under their inputs with aria-describedby. Then confirm the load-time alerts are not using role="alert", or a screen reader will announce them over the rest of the page.

关于 警示条 的常见问题

如何用 AI 生成警示条组件?

描述严重级别、结构组成,以及警示条能否关闭 — 例如"信息、成功、警告、错误四种警示条,带左侧强调色条、图标、标题、说明文字和可选操作链接" — MeDo 就会从这一段描述里生成全部四种变体。因为它们是一起产出的,各级别之间的内边距、圆角和图标尺寸都保持一致。

警示条和 Toast 提示有什么区别?

内嵌警示条存在于页面布局里,会一直保留到它所描述的状况发生改变,因此适合用户可能需要反复查看的状态:账单问题、维护公告、表单错误。Toast 是浮在页面之上、几秒后自动消失的瞬时提示,适合确认用户刚刚完成的操作。如果消息在滚动或刷新之后仍必须存在,就用警示条。

警示条应该可以关闭吗?

只有当消息属于纯信息告知、用户错过也没有损失时才可以。如果警示条描述的是尚未解决的问题,就让它长期驻留,等状态解决后自行消失,否则关闭动作会掩盖一个仍需处理的问题。常见的折中做法是允许关闭,但在问题修复前的下一次会话中再次出现。

警示条能不用颜色传达严重程度吗?

必须能。给每个级别配一个形状不同的图标,再用直接点明状况的文案,这样灰度屏幕或色盲读者也能收到信息。在提示词里要求 MeDo 采用"图标 + 文字"的编码方式,它就会为每个级别分配不同字形,而不是把同一个图标换四种颜色。

表单错误警示条应该放在哪里?

汇总警示条放在提交区域正上方或表单顶部,各条具体消息放在对应字段下方,并用 aria-describedby 和 aria-invalid 关联。汇总告诉用户一共有多少问题,字段级消息告诉他们具体要改什么;两者都有,键盘用户和读屏用户才不必四处找错误在哪。

警示条需要 role="alert" 吗?

并非总是需要。只在消息是动态出现且需要打断用户时才用 role="alert",例如提交后出现的校验失败。页面加载时就已存在的警示条应该用普通 region 或 role="status",因为在首次渲染时使用 assertive 实时区域,只会把页面上其他所有内容都盖过去。