TreeviewNode

Data Display
stable

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.

Anatomy of OrigamTreeviewNodeSchematic of the TreeviewNode component with 8 numbered internal parts. › 📁 node.label size #node slot origam-treeview-node (recursive children) 1 2 3 4 5 6 7 8 origam-treeview-node ③ guide lines · ④ chevron · ⑤ icon · ⑥ label · ⑦ size — inside ② row; ⑧ = recursive children
Anatomy of <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 the node.label value.
7.origam-treeview-node__size
Optional size badge. Only rendered when node.size is 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.

node
required
ITreeviewNode
—
The node data object. Shape: { id, label, icon?, size?, children?, disabled?, expandable? }.
depth
number
0
Nesting depth level used to compute the inline-start indent via CSS calc. Automatically incremented for child nodes.
id
string
class
string | Array<string> | object
style
string | 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

treeitem

Keyboard interactions

Keyboard interactions
KeyAction
Enter / SpaceSelects the node (if selectable) or toggles expansion (if it has children and is not selectable).
ArrowRightIf collapsed and has children: expands. If expanded and has children: moves focus to first child.
ArrowLeftIf expanded: collapses the node. If collapsed: moves focus to the parent treeitem.
TabMoves 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.

Source
dimension
var(--origam-space---4)
Indent per depth level.
dimension
var(--origam-space---8)
Minimum row height.
color
var(--origam-color__surface---overlay)
Row background on hover.
color
var(--origam-color__action--primary---bgSubtle)
Row background when selected.
dimension
var(--origam-font__size---sm)
Font size of the node label.
color
var(--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)

vue

Ecosystem

Family

Components from the same folder that share conventions and often compose together.