Treeview

Data Display
stable

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 tree

Rendering the live preview…

single select

Rendering the live preview…

no lines

Rendering the live preview…

colored selection

Structure

Anatomy

Visual breakdown of the component's internal structure with BEM class call-outs.

Anatomy of OrigamTreeviewSchematic showing the Treeview root and one TreeviewNode with its parts. src/ › main.ts App.vue 1 2 3 4
Anatomy of <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.

items
required
ITreeviewNode[]
[]
Array of ITreeviewNode objects defining the tree. Each node has id, label, optional icon, size, disabled, expandable and children fields.
modelValue
string[] | string
v-model for the selected node id(s). String for single, string[] for multiple selection.
expandedValue
string[]
Array of expanded node ids. Synced via the update:expandedValue emit.
selectMode
'none'
Selection behavior: none (no selection), single (one at a time) or multiple (checkbox-style).
selectableNodes
'leaf'
Which nodes can be selected: leaf (only leaf nodes), branch (only parents) or all.
showLines
boolean
true
Renders vertical guide lines connecting sibling nodes at each depth level.
expandOnClick
boolean
false
When true, clicking anywhere on the row expands/collapses it. When false, only the chevron icon triggers expand.
ariaLabel
string
id
string
class
string | Array<string> | object
style
string | Array<string> | object | StyleValue
color
Color applied to selected nodes (row background and text). Accepts semantic intents.
bgColor
TColor
size
'default'
Controls icon and chevron size via the size token scale.
density
'default'
Row height density.

API

Slots

Content slots exposed by this component.

#node

API

Emits

Events emitted by this component.

@update:modelValue
string[] | string
Fired when the selected set changes.
@update:expandedValue
string[]
Fired when a node is expanded or collapsed.
@select
string
Fired when a node is selected. Payload is the node id.
@toggle
string, 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

tree
treeitem

Keyboard interactions

Keyboard interactions
KeyAction
ArrowRightExpands a collapsed node, or moves focus to the first child of an already-expanded node.
ArrowLeftCollapses an expanded node, or moves focus to the parent node.
ArrowDown / ArrowUpMoves focus to the next/previous visible node in the tree.
Enter / SpaceSelects 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.

Source
color
var(--origam-color__surface---default)
Tree background.
color
var(--origam-color__action--primary---bgSubtle)
Row background when selected.
dimension
var(--origam-space---4)
Indentation per depth level.
color
var(--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

vue

Single selection

vue

Ecosystem

Family

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