Treeview
Hierarchical tree structure with expand/collapse, single/multi selection and optional guide lines. Items are defined via a typed ITreeviewNode list.
Preview
Rendering the live preview…
default treeRendering the live preview…
single selectRendering the live preview…
no linesRendering the live preview…
colored selectionStructure
Anatomy
Visual breakdown of the component's internal structure with BEM class call-outs.
<origam-treeview> — the root ① is a role="tree" container; each node ② is a role="treeitem" with a chevron ③ and recursive children ④.- 1.origam-treeview
- Root element. role="tree", aria-multiselectable when selectMode="multiple".
- 2.origam-treeview-node
- Each node row. role="treeitem". aria-selected, aria-expanded, aria-disabled are set dynamically.
- 3.origam-treeview-node__chevron
- Expand/collapse indicator. Rotated 90° when the node is expanded.
- 4.origam-treeview-node__children
- Container for child nodes. Indented by indent-size per depth level.
API
Props
All props accepted by this component, with their type, default value and description.
- itemsrequiredITreeviewNode[][]
- Array of ITreeviewNode objects defining the tree. Each node has id, label, optional icon, size, disabled, expandable and children fields.
- modelValuestring[] | string
- v-model for the selected node id(s). String for single, string[] for multiple selection.
- expandedValuestring[]
- Array of expanded node ids. Synced via the update:expandedValue emit.
- Selection behavior: none (no selection), single (one at a time) or multiple (checkbox-style).
- Which nodes can be selected: leaf (only leaf nodes), branch (only parents) or all.
- showLinesbooleantrue
- Renders vertical guide lines connecting sibling nodes at each depth level.
- expandOnClickbooleanfalse
- When true, clicking anywhere on the row expands/collapses it. When false, only the chevron icon triggers expand.
- ariaLabelstring
- idstring
- classstring | Array<string> | object
- stylestring | Array<string> | object | StyleValue
- color
- Color applied to selected nodes (row background and text). Accepts semantic intents.
- bgColorTColor
- Controls icon and chevron size via the size token scale.
- Row height density.
API
Slots
Content slots exposed by this component.
- #node
API
Emits
Events emitted by this component.
- @update:modelValuestring[] | string
- Fired when the selected set changes.
- @update:expandedValuestring[]
- Fired when a node is expanded or collapsed.
- @selectstring
- Fired when a node is selected. Payload is the node id.
- @togglestring, boolean
- Fired when a node is expanded/collapsed. Payload: (id, expanded).
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.
- (id: string) => boolean
- Returns true if the given node id is currently expanded.
- (id: string) => boolean
- Returns true if the given node id is in the selected set.
- (id: string) => void
- Programmatically expand or collapse a node by id.
- (id: string) => void
- Programmatically select or deselect a node by id.
- Ref<string>
- Reactive CSS string for computed styles.
- string
- Unique style-sheet ID.
- () => void
- Injects the style sheet on mount.
- () => void
- Removes the style sheet on unmount.
- Ref<boolean>
- True once the style sheet has been injected.
Customisation
CSS variables
CSS custom properties exposed by this component. Override them to customise the component without losing theme compatibility.
- Treeview background color.
- Default node text color.
- Per-depth indentation size.
- Height of each tree row.
- Row background on hover.
- Row background when selected.
- Color of the vertical guide lines (show-lines).
Inclusion
Accessibility
ARIA roles, keyboard navigation and focus management. Sourced from the real component template.
ARIA roles
Keyboard interactions
| Key | Action |
|---|---|
| ArrowRight | Expands a collapsed node, or moves focus to the first child of an already-expanded node. |
| ArrowLeft | Collapses an expanded node, or moves focus to the parent node. |
| ArrowDown / ArrowUp | Moves focus to the next/previous visible node in the tree. |
| Enter / Space | Selects the focused node (when selectMode is not none). |
Notes
- Root element has role="tree"; each node has role="treeitem". aria-selected, aria-expanded and aria-disabled are set reactively.
- aria-multiselectable is set to true on the tree root when selectMode="multiple".
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.
- colorvar(--origam-color__surface---default)
- Tree background.
- colorvar(--origam-color__action--primary---bgSubtle)
- Row background when selected.
- dimensionvar(--origam-space---4)
- Indentation per depth level.
- colorvar(--origam-color__border---subtle)
- Guide line color.
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.
Basic file tree
Single selection
Ecosystem
Family
Components from the same folder that share conventions and often compose together.