Components · Navigation & Layout
Tabs
Switches between related views in the same place.
Component Workbench
Switch between the live interactive preview, syntax-highlighted implementation code, copyable AI coding agent prompt, and designer anatomy blueprint.
Tabs · Canonical Spec
Active nodes: 3 worker instances running kernel 6.8 with zero evictions.
Storage: 4 NVMe-backed SSD volumes attached across availability zones.
Network: Ingress mesh router handling 14,290 requests/sec with TLS termination.
<div class="as-tabs">
<div class="as-tabs__list" role="tablist" aria-orientation="horizontal">
<button type="button" class="as-tabs__tab is-active" role="tab" id="tab-1" aria-selected="true" aria-controls="panel-1" tabindex="0">Worker Nodes</button>
<button type="button" class="as-tabs__tab" role="tab" id="tab-2" aria-selected="false" aria-controls="panel-2" tabindex="-1">Storage Volumes</button>
</div>
<div class="as-tabs__panel is-active" role="tabpanel" id="panel-1" aria-labelledby="tab-1" tabindex="0">Active nodes...</div>
<div class="as-tabs__panel" role="tabpanel" id="panel-2" aria-labelledby="tab-2" tabindex="0" hidden>Storage volumes...</div>
</div> # Aster Component Implementation Prompt — Tabs
## 1. Component Purpose & Canonical Role
- **Component:** Tabs (`tabs`)
- **Category:** Navigation & Layout
- **Native Element:** `<div role="tablist"> + <div role="tabpanel">`
- **Summary:** Switches between related views in the same place.
- **When to Use:** Switching between sibling sub-views (e.g. Preview, Code, Prompt, Anatomy).
- **When Not to Use:** Sequential multi-step wizards.
## 2. Authoritative Repository Files
- **Component CSS:** `components/tabs/tabs.css`
- **Component Spec:** `docs/components/tabs.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-tabs">
<div class="as-tabs__list" role="tablist" aria-orientation="horizontal">
<button type="button" class="as-tabs__tab is-active" role="tab" id="tab-1" aria-selected="true" aria-controls="panel-1" tabindex="0">Worker Nodes</button>
<button type="button" class="as-tabs__tab" role="tab" id="tab-2" aria-selected="false" aria-controls="panel-2" tabindex="-1">Storage Volumes</button>
</div>
<div class="as-tabs__panel is-active" role="tabpanel" id="panel-1" aria-labelledby="tab-1" tabindex="0">Active nodes...</div>
<div class="as-tabs__panel" role="tabpanel" id="panel-2" aria-labelledby="tab-2" tabindex="0" hidden>Storage volumes...</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 short labels.
- Keep content that people don't need to compare side by side.
Don't
- Use tabs for steps in a sequence.
- Use so many tabs that they wrap or scroll.
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 Left / Right | Cycles active tab and reveals associated tabpanel. |
| Roving Tabindex | Active tab sets tabindex="0"; inactive tabs set tabindex="-1". |
Tokens
Values update with the current theme.
| Role | Token | Current value |
|---|---|---|
| Active Indicator | --as-semantic-color-interactive-primary | |
| Divider Border | --as-semantic-color-border-subtle |