Treeview
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 treeRendu de l’aperçu en cours…
single selectRendu de l’aperçu en cours…
no linesRendu de l’aperçu en cours…
colored selectionStructure
Anatomie
Décomposition visuelle de la structure interne du composant avec les appels de classes BEM.
<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.
- itemsrequisITreeviewNode[][]
- 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
Emplacements de contenu exposés par ce composant.
- #node
API
Emits
Événements émis par ce composant.
- @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
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
Interactions clavier
| Touche | 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".
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.
- 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.
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
Single selection
Écosystème
Famille
Composants du même dossier qui partagent les conventions et se composent souvent ensemble.