TreeviewNode
Single node in a Treeview — renders chevron, icon, label and size badge; recursively renders children when expanded. Handles its own expand/select keyboard interactions.
Structure
Anatomy
Visual breakdown of the component's internal structure with BEM class call-outs.
<origam-treeview-node> — 8 parts. The root wrapper holds the interactive row (with guide lines, chevron, icon, label and size) followed by the optional node slot and the recursive children group.- 1.origam-treeview-node
- Root wrapper,
role="none". Flex column, no ARIA role — ARIA is on the inner row. - 2.origam-treeview-node__row
- Interactive row.
role="treeitem",aria-expanded,aria-selected,aria-disabled,tabindex. Handles click and keyboard events. - 3.origam-treeview-node__guide
- Vertical guide line repeated once per depth level (depth > 0 and showLines=true).
aria-hidden="true". - 4.origam-treeview-node__chevron
- Expand/collapse indicator. Rotates 90° when expanded. Invisible (
visibility: hidden) on leaf nodes. - 5.origam-treeview-node__icon
- Node icon — custom
node.icon, or a folder emoji (expanded/collapsed), or a document emoji for leaves.aria-hidden="true". - 6.origam-treeview-node__label
- Node label text.
flex: 1, truncated with ellipsis. Uses thenode.labelvalue. - 7.origam-treeview-node__size
- Optional size badge. Only rendered when
node.sizeis provided. - 8.origam-treeview-node__children
- Children container,
role="group",aria-label="{node.label} contents". Shown only when expanded. Recursively renders<OrigamTreeviewNode>for each child.
API
Props
All props accepted by this component, with their type, default value and description.
- noderequiredITreeviewNode—
- The node data object. Shape: { id, label, icon?, size?, children?, disabled?, expandable? }.
- depthnumber0
- Nesting depth level used to compute the inline-start indent via CSS calc. Automatically incremented for child nodes.
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
API
Slots
Content slots exposed by this component.
- #node
- Custom render slot injected after the row. Receives the current node data, depth, expanded and selected states. Forwarded recursively to all child OrigamTreeviewNode instances.
API
Exposed members
Properties and methods accessible via template ref (defineExpose). Use them for programmatic control.
- <T extends object>(props: T, exclude?: string[]) => Partial<T>
- Utility to forward a filtered subset of props to a child component.
- ComputedRef<boolean>
- Reactive ref: true when this node is currently expanded.
- ComputedRef<boolean>
- Reactive ref: true when this node is currently selected.
- Ref<string>
- Reactive CSS string generated by useStyle.
- string
- Unique style-sheet ID for this instance.
- () => void
- Injects the computed style sheet into the document.
- () => void
- Removes the injected style sheet.
- Ref<boolean>
- True once the style sheet has been injected into the DOM.
Customisation
CSS variables
CSS custom properties exposed by this component. Override them to customise the component without losing theme compatibility.
- Indent per depth level. Applied via CSS calc on the row padding-inline-start.
- Minimum row height.
- Horizontal padding added to the base indent on the row.
- Row background on hover.
- Row background when selected.
- Label color when selected.
- Label color when disabled.
- Width and height of the chevron element.
- Color of the chevron glyph.
- Color of the vertical guide lines.
- Thickness of the vertical guide lines.
- Font size of the node label.
- Font size of the node icon.
Inclusion
Accessibility
ARIA roles, keyboard navigation and focus management. Sourced from the real component template.
ARIA roles
Keyboard interactions
| Key | Action |
|---|---|
| Enter / Space | Selects the node (if selectable) or toggles expansion (if it has children and is not selectable). |
| ArrowRight | If collapsed and has children: expands. If expanded and has children: moves focus to first child. |
| ArrowLeft | If expanded: collapses the node. If collapsed: moves focus to the parent treeitem. |
| Tab | Moves focus out of the tree to the next focusable element in the page. |
Notes
- OrigamTreeviewNode uses a wrapper with role="none" and an inner interactive div with role="treeitem". ARIA attributes (aria-expanded, aria-selected, aria-disabled, aria-label) are applied to the inner row only.
- The children container uses role="group" with aria-label="{node.label} contents" as required by the ARIA tree pattern.
- Focus-visible outline is applied on the row via :focus-visible (2px solid, outline-offset: -2px).
- Guide lines, chevron and icon are all aria-hidden="true". Only the label contributes to the accessible name (supplemented by aria-label="node.label" on the treeitem).
Foundation
Design tokens
Excerpt from this component's token declarations — the --origam-<component>---<property> variables, declared in its hand-maintained token sheet with no build step.
- dimensionvar(--origam-space---4)
- Indent per depth level.
- dimensionvar(--origam-space---8)
- Minimum row height.
- colorvar(--origam-color__surface---overlay)
- Row background on hover.
- colorvar(--origam-color__action--primary---bgSubtle)
- Row background when selected.
- dimensionvar(--origam-font__size---sm)
- Font size of the node label.
- colorvar(--origam-color__border---subtle)
- Color of the vertical guide lines.
Interactive
Playground
Edit props live and see the component update in real time. The generated code snippet updates as you change values.
Rendering the live preview…
Usage
Examples
Ready-to-paste code snippets for your templates.
Standalone node (inside a treeview)
Ecosystem
Family
Components from the same folder that share conventions and often compose together.