Components · Data Display
Badge
A small label for a status or category.
Component Workbench
Switch between the live interactive preview, syntax-highlighted implementation code, copyable AI coding agent prompt, and designer anatomy blueprint.
Badge · Canonical Spec
Healthy
Rebalancing
Degraded
v2.4.1
Internal
<span class="as-badge as-badge--success">
<span class="as-badge__dot"></span>Healthy
</span>
<span class="as-badge as-badge--warning">
<span class="as-badge__dot"></span>Rebalancing
</span>
<span class="as-badge as-badge--critical">Degraded</span> # Aster Component Implementation Prompt — Badge ## 1. Component Purpose & Canonical Role - **Component:** Badge (`badge`) - **Category:** Data Display - **Native Element:** `<span>` - **Summary:** A small label for a status or category. - **When to Use:** Status cells in tables, card headers, and metadata tags. - **When Not to Use:** Interactive clickable actions (use Button). ## 2. Authoritative Repository Files - **Component CSS:** `components/badge/badge.css` - **Component Spec:** `docs/components/badge.md` - **Agent Contract:** `skills/using-aster-components/SKILL.md` - **Compiled Bundle:** `dist/css/aster.css` and `dist/js/aster.js` ## 3. Canonical HTML Structure & Classes ```html <span class="as-badge as-badge--success"> <span class="as-badge__dot"></span>Healthy </span> <span class="as-badge as-badge--warning"> <span class="as-badge__dot"></span>Rebalancing </span> <span class="as-badge as-badge--critical">Degraded</span> ``` ## 4. Measured Geometry Measured from the rendered component when this page loads. ## 5. Non-Negotiable Aster Constraints 1. **Zero Primitive Color Leaks:** Bind colors strictly to `--as-semantic-color-*` custom properties. Never use `--as-color-primitive-*` or hardcoded hex values in component usage. 2. **Minimum 4px Radius Policy:** Never use `2px` border-radius. Use `--as-radius-sm` (`4px`), `--as-radius-md` (`8px`), `--as-radius-lg` (`12px`), or `--as-radius-full` (`9999px`). 3. **Single Standard Density Mode:** Compact mode (`data-density="compact"` / `.as-*--compact`) is permanently retired. Do not emit compact classes or attributes. 4. **WCAG 2.2 AA Accessibility:** Maintain >= 4.5:1 text contrast, >= 3:1 UI/border contrast, >= 24x24px interactive hit targets, and full keyboard operability (`Tab`, `Enter`, `Space`, `Escape`, Arrow keys). ## 6. Verification Commands ```bash npm run test:components npm run test:contrast npm run test:browser ```
When to use it
Do
- Keep the text to one or two words.
- Use the same variant for the same status everywhere.
Don't
- Make it clickable. Use Button instead.
- Rely on color alone. Always include text.
Variants & States
Every option, rendered live with real styles.
Accessibility & Keyboard Interaction
Requirements for using this component accessibly, following the W3C ARIA Authoring Practices Guide.
| Interaction / Key | Behavior & Compliance Requirement |
|---|---|
| Non-Color-Alone | Conveys state via explicit text labels (WCAG 1.4.1). |
| Contrast | Passes 4.5:1 text contrast in both themes. |
Tokens
Values update with the current theme.
| Role | Token | Current value |
|---|---|---|
| Success Text | --as-semantic-color-status-success-text | |
| Warning Text | --as-semantic-color-status-warning-text | |
| Critical Text | --as-semantic-color-status-critical-text |