Category
A two-pane category navigation: a multi-level tree on the left (expand/collapse) and a grid of the active category's children on the right; leaf categories list product slots. Both panes stay in sync, with keyboard tree navigation.
Basic usage
categories injects the tree: children are subcategories, items are leaf product slots.
Linked panes
Events
oas-change: emitted when a left node is selected or a subcategory is entered from the right; detail{ key, path, node }(path runs from the root to the active category)oas-select: emitted when a product slot is clicked; detail{ key, item, path }
Linked feedback
Multi-level expansion
Tree keys: ↑ / ↓ move, → expands or enters the first child, ← collapses or returns to the parent, Enter / Space selects. aria-expanded / aria-level follow the hierarchy. Clicking an expanded parent collapses it; the right pane keeps showing its child grid.
Multi-level
Empty state
When categories is absent, invalid JSON or an empty array, an empty state is rendered without throwing.
Empty
Data contract
json
[
{
"key": "digital",
"label": "Digital",
"children": [{ "key": "phone", "label": "Phones", "items": [{ "key": "p1", "label": "Bluetooth headphones", "meta": "Hot" }] }]
}
]keyis required and must be unique (falls back toid/label/namewhen absent)childrenare subcategories with no depth limit;itemsare product slots (label+ optionalmeta)active-keyis controlled: writing it from outside expands its path; absent selects the first root- The same-named property channel works too:
categoriesaccepts an array directly (serialized and reflected into the JSON attribute; the getter returns the parsed nodes)
API
oas-category
Attributes
| Attribute | Description | Type | Default |
|---|---|---|---|
active-key | Active category key (controlled); writing it expands its path, absent selects the first root | string | — |
categories | Category tree (host-injected): JSON array [{ key?, id?, label?, name?, children?, items? }]; keys are globally unique, children are recursive, items are product slots [{ key, label, meta? }] | CategoryNode[] | string | [] |
Events
| Event | Description |
|---|---|
oas-change | Emitted when a left node is selected or a subcategory is entered from the right; detail { key, path, node } (path runs from root to the active category) |
oas-select | Emitted when a product slot is clicked; detail |
CSS Variables
| CSS Variable | Default |
|---|---|
--oas-category-height | 24rem |
--oas-category-side-height | 12rem |
--oas-category-side-width | 9rem |