Components · Form Controls
Checkbox
Lets people turn independent options on or off.
Component Workbench
Switch between the live interactive preview, syntax-highlighted implementation code, copyable AI coding agent prompt, and designer anatomy blueprint.
Checkbox · Canonical Spec
<label class="as-checkbox-field">
<span class="as-checkbox">
<input type="checkbox" class="as-checkbox-input" checked>
</span>
<span class="as-checkbox-field__content">
<span class="as-checkbox-field__label">Enforce Zero-Trust Ingress</span>
<span class="as-checkbox-field__description">Drop unauthenticated packets.</span>
</span>
</label> # Aster Component Implementation Prompt — Checkbox
## 1. Component Purpose & Canonical Role
- **Component:** Checkbox (`checkbox`)
- **Category:** Form Controls
- **Native Element:** `<input type="checkbox">`
- **Summary:** Lets people turn independent options on or off.
- **When to Use:** Multi-select lists, table row selection, or boolean acknowledgments.
- **When Not to Use:** Mutually exclusive choices (use Radio Group) or instant system toggles (use Switch).
## 2. Authoritative Repository Files
- **Component CSS:** `components/checkbox/checkbox.css`
- **Component Spec:** `docs/components/checkbox.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
<label class="as-checkbox-field">
<span class="as-checkbox">
<input type="checkbox" class="as-checkbox-input" checked>
</span>
<span class="as-checkbox-field__content">
<span class="as-checkbox-field__label">Enforce Zero-Trust Ingress</span>
<span class="as-checkbox-field__description">Drop unauthenticated packets.</span>
</span>
</label>
```
## 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 when several options can be chosen.
- Use the mixed state only for a parent of partly selected items.
Don't
- Use it when only one option is allowed. Use Radio instead.
- Use it for settings that apply instantly. Use Switch instead.
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 |
|---|---|
Space | Toggles checked state natively. |
| Target Size | 28x28px hit target exceeds WCAG 2.5.8 24px minimum. |
Tokens
Values update with the current theme.
| Role | Token | Current value |
|---|---|---|
| Checked Fill | --as-semantic-color-interactive-primary | |
| Corner Radius | --as-radius-sm |