Skip to content

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

Active: digital

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" }] }]
  }
]
  • key is required and must be unique (falls back to id / label / name when absent)
  • children are subcategories with no depth limit; items are product slots (label + optional meta)
  • active-key is controlled: writing it from outside expands its path; absent selects the first root
  • The same-named property channel works too: categories accepts an array directly (serialized and reflected into the JSON attribute; the getter returns the parsed nodes)

API ​

oas-category ​

Attributes ​

AttributeDescriptionTypeDefault
active-keyActive category key (controlled); writing it expands its path, absent selects the first rootstring—
categoriesCategory 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 ​

EventDescription
oas-changeEmitted 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-selectEmitted when a product slot is clicked; detail

CSS Variables ​

CSS VariableDefault
--oas-category-height24rem
--oas-category-side-height12rem
--oas-category-side-width9rem

Released under the MIT OR Apache-2.0 License.