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 外環,圓點在複雜照片上也能看清。若容器會裁切子元素,就把圓角移到內層元素上。