Components · Feedback & Status
Alert
A message in the page about something people should notice.
Component Workbench
Switch between the live interactive preview, syntax-highlighted implementation code, copyable AI coding agent prompt, and designer anatomy blueprint.
Alert · Canonical Spec
Scheduled Rolling Kernel Upgrade
Node pool eu-west-1a will drain active pods in 45 minutes. Click the red dot button to dismiss.
<div class="as-alert as-alert--warning" role="region" aria-labelledby="alert-title">
<svg class="as-alert__icon" viewBox="0 0 16 16" aria-hidden="true">...</svg>
<div class="as-alert__content">
<div class="as-alert__title" id="alert-title">Maintenance Notice</div>
<div class="as-alert__description">Worker node drain initiated.</div>
</div>
<button type="button" class="as-alert__close" aria-label="Dismiss alert"></button>
</div> # Aster Component Implementation Prompt — Alert
## 1. Component Purpose & Canonical Role
- **Component:** Alert (`alert`)
- **Category:** Feedback & Status
- **Native Element:** `<div role="region|alert">`
- **Summary:** A message in the page about something people should notice.
- **When to Use:** Contextual system warnings, maintenance notices, or error summaries.
- **When Not to Use:** Transient floating confirmations (use Toast).
## 2. Authoritative Repository Files
- **Component CSS:** `components/alert/alert.css`
- **Component Spec:** `docs/components/alert.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
<div class="as-alert as-alert--warning" role="region" aria-labelledby="alert-title">
<svg class="as-alert__icon" viewBox="0 0 16 16" aria-hidden="true">...</svg>
<div class="as-alert__content">
<div class="as-alert__title" id="alert-title">Maintenance Notice</div>
<div class="as-alert__description">Worker node drain initiated.</div>
</div>
<button type="button" class="as-alert__close" aria-label="Dismiss alert"></button>
</div>
```
## 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
- Say what happened and what to do next.
- Match the variant to the real severity.
Don't
- Use it for quick confirmations. Use Toast instead.
- Stack several alerts in one place.
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 |
|---|---|
| Role Region / Alert | Uses role="region" for static notices and role="alert" for urgent errors. |
| Red Dot Close Button | 12px solid red dot with aria-label="Dismiss alert" and 2px focus ring. |
Tokens
Values update with the current theme.
| Role | Token | Current value |
|---|---|---|
| Corner Radius | --as-radius-md | |
| Warning Surface | --as-semantic-color-surface-warning | |
| Warning Text | --as-semantic-color-status-warning-text |