Components · Form Controls
Button
Starts an action, such as saving or deleting.
Component Workbench
Switch between the live interactive preview, syntax-highlighted implementation code, copyable AI coding agent prompt, and designer anatomy blueprint.
Button · Canonical Spec
<!-- Primary Monochrome Pill Action (48px height, 16px vertical and 24px horizontal padding) -->
<button type="button" class="as-button as-button--primary">
<span class="as-button__label">Deploy Cluster</span>
</button>
<!-- Secondary Outlined Action -->
<button type="button" class="as-button as-button--secondary">
<span class="as-button__label">Cancel</span>
</button>
<!-- Destructive & Ghost Actions -->
<button type="button" class="as-button as-button--destructive">
<span class="as-button__label">Terminate Node</span>
</button>
<button type="button" class="as-button as-button--ghost">
<span class="as-button__label">Inspect Logs</span>
</button> # Aster Component Implementation Prompt — Button ## 1. Component Purpose & Canonical Role - **Component:** Button (`button`) - **Category:** Form Controls - **Native Element:** `<button>` - **Summary:** Starts an action, such as saving or deleting. - **When to Use:** Form submissions, modal confirmations, workflow triggers, and primary commands. - **When Not to Use:** Navigating between pages or documentation sections (use semantic <a> anchor elements). ## 2. Authoritative Repository Files - **Component CSS:** `components/button/button.css` - **Component Spec:** `docs/components/button.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 <!-- Primary Monochrome Pill Action (48px height, 16px vertical and 24px horizontal padding) --> <button type="button" class="as-button as-button--primary"> <span class="as-button__label">Deploy Cluster</span> </button> <!-- Secondary Outlined Action --> <button type="button" class="as-button as-button--secondary"> <span class="as-button__label">Cancel</span> </button> <!-- Destructive & Ghost Actions --> <button type="button" class="as-button as-button--destructive"> <span class="as-button__label">Terminate Node</span> </button> <button type="button" class="as-button as-button--ghost"> <span class="as-button__label">Inspect Logs</span> </button> ``` ## 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
- Start the label with a verb, such as "Save changes".
- Use one primary button per area.
Don't
- Use it to go to another page. Use Link instead.
- Disable it without explaining why.
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 |
|---|---|
| Native Semantics | Standard <button type="button"> avoids unintended form submissions. |
| Keyboard Trigger | Activated by both Enter and Space keys natively. |
| Focus-Retaining Disabled | Declares aria-disabled="true" to remain in tab order while blocking execution. |
| Async Loading | Sets aria-busy="true", renders .as-spinner, and blocks duplicate clicks. |
Tokens
Values update with the current theme.
| Role | Token | Current value |
|---|---|---|
| Primary Fill | --as-semantic-color-interactive-primary | |
| Text on Primary | --as-semantic-color-interactive-primary-text | |
| Horizontal Padding | --as-space-6 | |
| Control Height | --as-space-12 | |
| Pill Radius | --as-radius-full |