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.

Aperçu

Rendu de l’aperçu en cours…

default tree

Rendu de l’aperçu en cours…

single select

Rendu de l’aperçu en cours…

no lines

Rendu de l’aperçu en cours…

colored selection

Structure

Anatomie

Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.

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

Toutes les props acceptées par ce composant, avec leur type, valeur par défaut et description.

items
requis
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

Emplacements de contenu exposés par ce composant.

#node

API

Emits

Événements émis par ce composant.

@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

Membres exposés

Propriétés et méthodes accessibles via ref template (defineExpose). Utilisés pour le contrôle programmatique.

<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.

Personnalisation

Variables CSS

Propriétés CSS personnalisées exposées par ce composant. Surchargez-les pour personnaliser sans perdre la compatibilité avec le thème.

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

Accessibilité

Rôles ARIA, navigation clavier et gestion du focus. Sourcé depuis le template réel du composant.

Rôles ARIA

tree
treeitem

Interactions clavier

Interactions clavier
ToucheAction
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".

Fondation

Design tokens

Extrait des tokens de ce composant — les variables --origam-<composant>---<propriété>, déclarées dans sa feuille de tokens tenue à la main, sans étape de build.

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.

Interactif

Playground

Modifiez les props en direct et observez le composant se mettre à jour. Le snippet de code généré suit vos changements.

Rendu de l’aperçu en cours…

Usage

Exemples

Extraits de code prêts à coller dans vos templates.

Basic file tree

vue

Single selection

vue

Écosystème

Famille

Composants du même dossier qui partagent les conventions et se composent souvent ensemble.