AI徽章生成器。

描述你的状态,MeDo生成整套徽章 — 语义化状态标签、可移除的标签片、带99+溢出的数字计数,以及叠在头像上也不会被裁切的圆点指示器。

徽章
徽章

徽章是体积最小、却最容易破坏布局的组件

徽章总是嵌在别的东西里:表格单元格、列表行、导航项、标题。这让它的固有高度成为一种布局依赖,而不只是样式选择。如果徽章的 line-height 比旁边的文字高出一个像素,它会悄悄拉伸表格的每一行,而这个问题往往被报成"表格显示不对",而不是徽章的问题。把徽章锁定在固定高度和固定 line-height 上,而不是交给内边距和字体度量去决定,才能让它随处可用。一次性生成整套组件,意味着每种色调和尺寸从结构上就共享同一套高度规范。

6 个模板

可以生成的 徽章 模板

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

BasicStatus Pill

Five-Tone Status Pill

The one you need first. Generating all five tones together is what keeps them on a single height scale, which is what makes the badge safe to drop into a table cell.

Create a status badge with five semantic tones — neutral grey, info blue, success green, warning amber, error red — each pairing a tinted background with a darker text color at 4.5:1 or better. Give it two sizes: sm at 18px tall with 11px text, md at 22px tall with 12px text, both at a 999px radius with 8px horizontal padding, a fixed line-height and inline-flex with align-items center, so a badge dropped into a table cell cannot change the row height. Always render a text label — the tone is redundant encoding, never the only signal. Render it as a span with no tabindex and no role, because a status badge is read-only output and adding a focus stop for it clutters keyboard navigation through a table.

在 MeDo 中尝试
NumericCount Badge

Notification Count With 99+ Clamping

A number, a min-width so single digits stay circular, and an announcement when it changes. Without the min-width the badge visibly changes shape as the count crosses from 9 to 10.

Create a numeric count badge that clamps displayed values above 99 to "99+" while keeping the true count in the accessible name. Set min-width equal to the badge height so a single digit renders as a circle rather than a narrow oval, use tabular-nums so the width does not jitter between values, and hide the badge entirely at zero rather than rendering an empty circle. Wrap the count in an element with role="status" and aria-live="polite" so an update is announced without interrupting, and phrase the accessible text as "3 unread messages" rather than a bare numeral. Do not use aria-live="assertive" — a count change almost never justifies cutting off whatever is being read.

在 MeDo 中尝试
AnchoredDot Indicator

Dot on an Icon or Avatar

An 8px circle overhanging the corner of a bell or an avatar. The failure is always the same: the wrapper has overflow: hidden for its rounding and clips the dot in half.

Create a dot indicator that anchors to the top-right of an icon or avatar: an 8px circle positioned absolutely with a small negative offset so it overhangs the edge, plus a 2px ring in the page surface color so it stays legible over a photo or a busy icon. Give the wrapper position: relative and explicitly no overflow: hidden — if the wrapper needs rounding, move the border-radius to an inner element so the dot is not clipped. Because a bare dot conveys nothing to a screen reader or a colorblind user, pair it with a visually hidden label naming the state or count. Mark the dot itself aria-hidden="true" so the label is announced once.

在 MeDo 中尝试
InteractiveRemovable Tag

Tag Chip With a Dismiss Button

The only variant that is a control rather than output. A dismiss glyph inside a div is why so many UIs ship tags a keyboard user cannot remove.

Create a removable tag chip: a label plus a dismiss control that is a real button element, not a span with a click handler, with aria-label naming the specific tag such as "Remove design" rather than a generic "Remove". Give the button a 16px glyph inside a 24px hit area, a visible focus ring, and Backspace or Delete as an alternative to Enter when it has focus. After removal, move focus to the next remaining chip, or to the group container when the last one is removed, so focus never lands on a detached node. Announce the removal through a polite live region. Keep the chip on the same height scale as the status badge so a row mixing both stays aligned.

在 MeDo 中尝试
With iconIcon + Label

Badge With a Leading Status Icon

A 12px glyph before the label for states that need to be identifiable in peripheral vision — a spinner for running, a check for passed, an octagon for failed in a CI list.

Create a badge variant with a 12px leading icon before the label, one distinct glyph per state so severity survives in grayscale: a check for passed, a spinning arc for running, an octagon for failed, a clock for queued. Mark the icon aria-hidden="true" since the label already carries the meaning. Keep the icon optically aligned to the text baseline rather than centered on the line box, and hold the overall badge height identical to the icon-less variant so a mixed column in a table does not develop two row heights. For the running state, drive the spin with a CSS animation and replace it with a static arc under prefers-reduced-motion rather than removing the icon.

在 MeDo 中尝试
SubtleOutline Badge

Bordered Badge for Dense Tables

A 1px border with a transparent fill, for screens where a column of tinted pills turns the table into a heat map. Also the variant that survives a dark theme without retinting.

Create an outlined badge variant: a 1px border in the tone color, a transparent background, and label text in the same tone at a darkened step so it holds 4.5:1 against both light and dark surfaces. Match the filled variant on height, radius, padding and line-height exactly, so the two can be swapped per column without any row reflowing — account for the 1px border inside the box by using box-sizing: border-box rather than reducing the padding. Provide a variant prop with filled and outline values on one component rather than a second component. Verify the border remains visible against a hovered table row background, which is the case that usually makes outline badges disappear.

在 MeDo 中尝试

如何自定义你的 徽章

按语义而非颜色命名色调

请使用 success、warning、error,而不是绿色、琥珀色、红色。语义化命名让你为深色模式或品牌改版重新调整配色时,不必改动每一处调用,也能一眼看出某个徽章是在做装饰,而非传达状态。

颜色务必搭配文字标签

单独一个红点对色盲用户毫无意义,对屏幕阅读器用户更是完全无声。请明确要求每个状态徽章都渲染文字;如果确实只需要一个圆点,请顺带要求一个视觉隐藏的标签,让状态仍能被朗读出来。

说明计数的溢出规则

明确超过阈值后的表现 — 通常截断为"99+" — 并为徽章设置 min-width,让单个数字的计数仍然是圆形而不是窄椭圆。没有 min-width,计数从9变成10时徽章形状会明显改变。

区分静态徽章与可交互标签片

状态徽章是文本,不应该可获得焦点。可移除标签是控件,需要真实的 button 来承担关闭动作,还需要焦点环和类似"移除 设计"的无障碍名称。请告诉MeDo你要哪一种,否则你会得到一个看起来能点、但键盘根本到不了的 div。

谁在使用 徽章 组件

SaaS 仪表盘

表格中的状态列,用同一高度规范的浅色标签显示"进行中""待处理""失败",把一行从进行中切换为失败时只改变颜色和文字,不会造成行位移。

电商店铺

页头购物车图标右上角锚定计数徽章,超过阈值截断为"99+";商品卡片上则复用同一套色调体系,显示"新品""库存紧张"标签。

项目管理工具

任务卡上表示标签和负责人的可移除标签片,每个都带有键盘可达的移除按钮,旁边是一个刻意不可交互的静态优先级徽章。

文档站点

API 标题旁的内联版本与稳定性徽章 — "Beta""已废弃""v2.1" — 使用固定 line-height,不会拉伸被标注的标题。

不同网站的 徽章 方案

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

01 / 06

SaaS Dashboards

A status column of Active, Pending and Failed pills, where the only thing that matters is that switching a row from one tone to another does not shift the row. Consider the outline variant once the table has more than about ten rows — a full column of tinted fills reads as a heat map.

徽章 的风格与变体

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

01 / 06

Filled Status Pill

A tinted background with darker text at a 999px radius — the default, and the most legible at 11px. Keep the tint light: a saturated fill at this size makes small text harder to read exactly where the label is doing the accessibility work.

在 React、Next.js、Vue 与 Svelte 中使用 徽章

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

01 / 06

React Badge

Stateless by definition — a status badge is output, so no hooks and no client boundary. Keep the tone map outside the component so the palette can be retuned in one place instead of at each call site.

src/components/Badge.tsx

const tones = {
  neutral: 'bg-zinc-100 text-zinc-700',
  success: 'bg-emerald-100 text-emerald-800',
  error: 'bg-red-100 text-red-800',
}

export function Badge({ tone = 'neutral', size = 'md', children }) {
  return (
    <span className={`inline-flex items-center rounded-full px-2
      ${sizes[size]} ${tones[tone]}`}>
      {children}
    </span>
  )
}

如何把 徽章 加入项目

四个步骤,从挑选 徽章 模板到上线生产环境。

01~30s

Pick a Badge Variant

Decide first whether you need output or a control: a status pill and a count are read-only, a tag chip is interactive. Then pick the tone set and the two sizes you actually need.

02~10s

Copy the Prompt

Take it into MeDo, Lovable, Bolt, v0 or Cursor. Name your tones semantically — success, warning, error — not by color, so a rebrand or a dark theme does not mean renaming every usage.

03~1min

Generate and Refine

You get the whole set on one height scale with a live preview. Follow up in plain English — "add an outline variant", "clamp at 999+", "make the dot ring match a dark surface" — instead of nudging padding values.

04~2min

Drop It Into a Table and Check the Row Height

Put a badge in a real table cell and a real heading, then compare row heights against a cell without one. If anything grew, the line-height is not pinned and the fix belongs in the component, not the table.

关于 徽章 的常见问题

如何用AI生成徽章组件?

在一个提示词里描述你需要的色调和模式,例如"五种语义状态色调,加上数字计数徽章和可移除标签片,各两种尺寸"。MeDo会生成共享高度规范、圆角和内边距的整套组件,而不是一个写死的单一标签。

徽章与标签(tag / chip)有什么区别?

徽章是只读输出:它报告状态或数量,不应该可获得焦点。标签或 chip 是用户可以操作的输入,通常可以移除,因此需要真实的 button、焦点样式和无障碍名称。把两者当成同一个组件,正是许多界面上线后键盘用户无法移除标签的原因。

徽章可以只用颜色表达状态吗?

不可以。WCAG 1.4.1 要求颜色不能是传达信息的唯一手段,所以一个没有文字的红色徽章对色盲用户和屏幕阅读器用户都是失败的。请在色调之外渲染文字标签,或用图标加视觉隐藏的标签。当你按语义描述色调时,MeDo默认会带上标签。

通知数量超过99该如何显示?

对显示值做截断,一旦超过阈值就渲染"99+";如果真实数量重要,把它保留在无障碍名称里。同时设置与徽章高度相等的 min-width,让个位数计数仍保持圆形而不是被压窄。

计数徽章需要向屏幕阅读器播报变化吗?

需要,前提是计数在没有页面跳转的情况下更新。把它包在 aria-live="polite" 区域中,新数值就能在不打断用户的情况下被播报;文案要简短 — "3 条未读"比一个孤零零的数字更好理解。这里请避免 aria-live="assertive",通知计数很少值得打断正在朗读的内容。

怎样把圆点徽章放在头像上而不被裁切?

给头像容器设置 position: relative 且不要用 overflow: hidden,然后用绝对定位加一点负偏移,让圆点略微超出圆形边缘。再加一个与页面背景同色的 2px 描边环,圆点在复杂照片上也能看清。如果容器会裁切子元素,就把圆角移到内层元素上。