Components · Overlays & Dialogs
Drawer
A panel that slides in from the edge and keeps the page in context.
Component Workbench
Switch between the live interactive preview, syntax-highlighted implementation code, copyable AI coding agent prompt, and designer anatomy blueprint.
Drawer · Canonical Spec
Node Telemetry Stream
Real-time metrics and kernel allocation.
Real-time stream connected. Node worker-01 running kernel 6.8 with zero dropped packets.
<div class="as-drawer" id="side-drawer" role="dialog" aria-modal="true" aria-labelledby="drawer-title" hidden>
<div class="as-drawer__backdrop" data-drawer-close></div>
<div class="as-drawer__panel as-drawer__panel--right">
<div class="as-drawer__header">
<h3 class="as-drawer__title" id="drawer-title">Node Telemetry</h3>
<button type="button" class="as-drawer__close" data-drawer-close aria-label="Close drawer"></button>
</div>
<div class="as-drawer__body">Telemetry details...</div>
</div>
</div> # Aster Component Implementation Prompt — Drawer
## 1. Component Purpose & Canonical Role
- **Component:** Drawer (`drawer`)
- **Category:** Overlays & Dialogs
- **Native Element:** `<div role="dialog" aria-modal="true">`
- **Summary:** A panel that slides in from the edge and keeps the page in context.
- **When to Use:** Telemetry inspectors, log streams, and multi-field configuration panels.
- **When Not to Use:** Simple yes/no confirmations (use Dialog).
## 2. Authoritative Repository Files
- **Component CSS:** `components/drawer/drawer.css`
- **Component Spec:** `docs/components/drawer.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-drawer" id="side-drawer" role="dialog" aria-modal="true" aria-labelledby="drawer-title" hidden>
<div class="as-drawer__backdrop" data-drawer-close></div>
<div class="as-drawer__panel as-drawer__panel--right">
<div class="as-drawer__header">
<h3 class="as-drawer__title" id="drawer-title">Node Telemetry</h3>
<button type="button" class="as-drawer__close" data-drawer-close aria-label="Close drawer"></button>
</div>
<div class="as-drawer__body">Telemetry details...</div>
</div>
</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
- Use it for detail views and longer settings.
- Keep the main actions in the footer.
Don't
- Use it for a simple yes or no. Use Dialog instead.
- Put a whole multi-step flow inside it.
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 |
|---|---|
| Focus Trap | Cycles Tab and Shift+Tab inside the open drawer. |
| Red Dot Close Button | 12px solid red dot .as-drawer__close with focus ring. |
Tokens
Values update with the current theme.
| Role | Token | Current value |
|---|---|---|
| Panel Surface | --as-semantic-color-surface-card | |
| Border Hairline | --as-semantic-color-border-subtle |