Components · Overlays & Dialogs
Dropdown Menu
A menu of actions behind one button.
Component Workbench
Switch between the live interactive preview, syntax-highlighted implementation code, copyable AI coding agent prompt, and designer anatomy blueprint.
Dropdown Menu · Canonical Spec
<div class="as-dropdown">
<button type="button" class="as-button as-button--secondary as-dropdown__trigger" id="menu-btn" aria-haspopup="menu" aria-expanded="false">
<span class="as-button__label">Cluster Operations</span>
</button>
<div class="as-dropdown__menu" role="menu" aria-labelledby="menu-btn" hidden>
<button type="button" class="as-dropdown__item" role="menuitem">Restart Active Pods</button>
<div class="as-dropdown__divider" role="separator"></div>
<button type="button" class="as-dropdown__item as-dropdown__item--destructive" role="menuitem">Drain Node Pool</button>
</div>
</div> # Aster Component Implementation Prompt — Dropdown Menu
## 1. Component Purpose & Canonical Role
- **Component:** Dropdown Menu (`dropdown`)
- **Category:** Overlays & Dialogs
- **Native Element:** `<div role="menu">`
- **Summary:** A menu of actions behind one button.
- **When to Use:** Row-level actions, overflow command menus, and contextual operations.
- **When Not to Use:** Form field option selection (use Select).
## 2. Authoritative Repository Files
- **Component CSS:** `components/dropdown/dropdown.css`
- **Component Spec:** `docs/components/dropdown.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-dropdown">
<button type="button" class="as-button as-button--secondary as-dropdown__trigger" id="menu-btn" aria-haspopup="menu" aria-expanded="false">
<span class="as-button__label">Cluster Operations</span>
</button>
<div class="as-dropdown__menu" role="menu" aria-labelledby="menu-btn" hidden>
<button type="button" class="as-dropdown__item" role="menuitem">Restart Active Pods</button>
<div class="as-dropdown__divider" role="separator"></div>
<button type="button" class="as-dropdown__item as-dropdown__item--destructive" role="menuitem">Drain Node Pool</button>
</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
- Group related actions and separate risky ones.
- Start each item with a verb.
Don't
- Use it to choose a form value. Use Select instead.
- Hide the most common action 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 |
|---|---|
| Arrow Up / Down | Roves focus cyclically through menu items. |
| Escape Key | Closes menu and restores focus to trigger button. |
Tokens
Values update with the current theme.
| Role | Token | Current value |
|---|---|---|
| Menu Radius | --as-radius-md | |
| Item Radius | --as-radius-sm |