Components · Form Controls
Radio Group
Lets people choose one option from a short list.
Component Workbench
Switch between the live interactive preview, syntax-highlighted implementation code, copyable AI coding agent prompt, and designer anatomy blueprint.
Radio Group · Canonical Spec
<fieldset class="as-radio-group">
<legend class="as-radio-group__legend">Rollout Strategy</legend>
<label class="as-radio-field">
<span class="as-radio"><input type="radio" name="strategy" class="as-radio-input" checked></span>
<span class="as-radio-field__content">
<span class="as-radio-field__label">Rolling Update</span>
</span>
</label>
</fieldset> # Aster Component Implementation Prompt — Radio Group
## 1. Component Purpose & Canonical Role
- **Component:** Radio Group (`radio`)
- **Category:** Form Controls
- **Native Element:** `<fieldset> + <input type="radio">`
- **Summary:** Lets people choose one option from a short list.
- **When to Use:** 2–5 mutually exclusive options that should all be visible at once.
- **When Not to Use:** Multi-select options (use Checkbox) or 6+ compact options (use Select).
## 2. Authoritative Repository Files
- **Component CSS:** `components/radio/radio.css`
- **Component Spec:** `docs/components/radio.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
<fieldset class="as-radio-group">
<legend class="as-radio-group__legend">Rollout Strategy</legend>
<label class="as-radio-field">
<span class="as-radio"><input type="radio" name="strategy" class="as-radio-input" checked></span>
<span class="as-radio-field__content">
<span class="as-radio-field__label">Rolling Update</span>
</span>
</label>
</fieldset>
```
## 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
- Show all the options, and name the group.
- Preselect a sensible default when you can.
Don't
- Use it for long lists. Use Select instead.
- Use it when several options can be chosen. Use Checkbox 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 |
|---|---|
| Arrow Keys | Moves selection and focus between radios in the group. |
| Fieldset & Legend | Grouped via <fieldset> and labeled by <legend>. |
Tokens
Values update with the current theme.
| Role | Token | Current value |
|---|---|---|
| Selected Dot | --as-semantic-color-interactive-primary | |
| Circle Radius | --as-radius-full |