GhostTree reference
Package: @ghostvue/vue. Status: experimental (stability policy).
Headless APG Tree View root (role="tree", default <ul>). Owns controlled/uncontrolled single or multiple selection (v-model) and expansion (v-model:expanded) through useControllableState, a single roving tab stop over visible enabled items in rendered DOM order, RTL-aware hierarchical arrow keys, Home/End, * sibling expansion, 500ms IME-safe typeahead, and focus recovery when an ancestor collapses or the focused item unmounts. Never mutates consumer data.
Generated from the component manifest. Edit the manifest or Vue source, then rebuild the docs.
Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
allowDeselect | boolean | false | No | In single mode, re-activating the selected node clears the selection. |
as | GhostTreeElement | "ul" | No | Tag name or component rendered for the `role="tree"` container. |
defaultExpanded | string[] | "[]" | No | Initial expanded branch values when `expanded` is omitted. |
defaultValue | GhostTreeValue | — | No | Initial uncontrolled selection. |
dir | GhostTreeDirection | — | No | Explicit writing direction; otherwise inherited from `[dir]`. |
disabled | boolean | false | No | Disables every interaction in the tree. |
expanded | string[] | — | No | Controlled expanded branch values (`v-model:expanded`). |
expandOnClick | boolean | true | No | Pointer clicks on a branch row also toggle expansion. |
loop | boolean | false | No | `ArrowDown` / `ArrowUp` wrap at the ends of the visible node list. |
modelValue | GhostTreeValue | — | No | Controlled selection (`v-model`). Omit for uncontrolled mode. |
selectionMode | GhostTreeSelectionMode | "single" | No | Single (`string | undefined`) or multiple (`string[]`) selection. |
Emits
| Name | Payload | Description |
|---|---|---|
select | GhostTreeSelectPayload | Emitted as `select`. |
toggle | GhostTreeTogglePayload | Emitted as `toggle`. |
Models
| Prop | Event | Type | Description |
|---|---|---|---|
expanded | update:expanded | string[] | v-model binding for `expanded`. |
modelValue | update:modelValue | GhostTreeValue | v-model binding for `modelValue`. |
Slots
| Name | Description |
|---|---|
default | GhostTreeItem nodes; receives selection, expansion, and focus state plus select/toggle helpers. |
Slot props: default
| Name | Type | Description |
|---|---|---|
expandAllSiblings | (value: string) => void | Slot prop `expandAllSiblings`. |
expanded | string[] | Slot prop `expanded`. |
focusedValue | string | undefined | Slot prop `focusedValue`. |
isExpanded | (value: string) => boolean | Slot prop `isExpanded`. |
isSelected | (value: string) => boolean | Slot prop `isSelected`. |
modelValue | GhostTreeValue | Slot prop `modelValue`. |
select | (value: string) => void | Slot prop `select`. |
toggleExpanded | (value: string) => void | Slot prop `toggleExpanded`. |
Exposed members
| Name | Type | Description |
|---|---|---|
blur | () => void | Exposed method `blur`. |
element | HTMLElement | null | Exposed property `element`. |
focus | (options?: FocusOptions) => void | Focuses the current roving tab stop item, if any. |
Parts and data attributes
| Attribute | Value | Description |
|---|---|---|
data-part | root | role="tree" container rendered by GhostTree. |
data-ghost-tree | present | Marker present on the GhostTree root. |
data-dir | ltr, rtl | Resolved writing direction on the GhostTree root. |
data-disabled | present | Present on the root when the whole tree is disabled. |
CSS variables
None declared.
Accessibility
Role: tree. APG pattern: https://www.w3.org/WAI/ARIA/apg/patterns/treeview/.
Required ARIA attributes: aria-label.
Keyboard
| Key | Action | Automated browser test |
|---|---|---|
Tab | Moves focus into and out of the tree through its single roving tab stop. | GhostTree @component:GhostTree › tree/basic: one Tab stop, every documented key, and Axe in both states (@ghostvue/vue) |
ArrowDown | Moves focus to the next visible enabled item without changing selection; wraps only when loop is true. | GhostTree @component:GhostTree › tree/basic: one Tab stop, every documented key, and Axe in both states (@ghostvue/vue) |
ArrowUp | Moves focus to the previous visible enabled item without changing selection; wraps only when loop is true. | GhostTree @component:GhostTree › tree/basic: one Tab stop, every documented key, and Axe in both states (@ghostvue/vue) |
ArrowRight | LTR: expands a closed branch, or moves to the first visible enabled child of an open branch. RTL: collapses an open branch, or moves to the closest visible enabled ancestor. | GhostTree @component:GhostTree › tree/basic: one Tab stop, every documented key, and Axe in both states (@ghostvue/vue) |
ArrowLeft | LTR: collapses an open branch, or moves to the closest visible enabled ancestor. RTL: expands a closed branch, or moves to the first visible enabled child of an open branch. | GhostTree @component:GhostTree › tree/basic: one Tab stop, every documented key, and Axe in both states (@ghostvue/vue) |
Home | Moves focus to the first visible enabled item. | GhostTree @component:GhostTree › tree/basic: one Tab stop, every documented key, and Axe in both states (@ghostvue/vue) |
End | Moves focus to the last visible enabled item. | GhostTree @component:GhostTree › tree/basic: one Tab stop, every documented key, and Axe in both states (@ghostvue/vue) |
Enter | Selects the focused item (single), deselects it when allowDeselect is true, or toggles it (multiple). Never toggles expansion. | GhostTree @component:GhostTree › tree/basic: one Tab stop, every documented key, and Axe in both states (@ghostvue/vue) |
| Same as Enter when no typeahead query is active; otherwise appends a space to the query. | GhostTree @component:GhostTree › tree/basic: one Tab stop, every documented key, and Axe in both states (@ghostvue/vue) |
* | Expands every closed enabled sibling branch of the focused item in one update. | GhostTree @component:GhostTree › tree/basic: one Tab stop, every documented key, and Axe in both states (@ghostvue/vue) |
a-z | Printable characters run a 500ms typeahead over visible enabled items, moving focus without selecting. | GhostTree @component:GhostTree › tree/basic: one Tab stop, every documented key, and Axe in both states (@ghostvue/vue) |
Verification
Each category is reviewed separately. Automated keyboard and axe results do not attest manual or assistive-technology review.
| Category | Status | Evidence |
|---|---|---|
| Automated keyboard | Passed | Every declared key maps to a Chromium browser test that CI runs and requires to pass on every commit. |
| Manual interaction | Not reviewed | No review recorded. |
| Assistive technology | Not reviewed | No review recorded. |
Examples
tree/basic
Single-selection file hierarchy with expand/collapse, one Tab stop, and arrow-key navigation.
tree/multi-select
selectionMode="multiple" with controlled v-model and v-model:expanded; Space toggles the focused node.
tree/split-trigger
A toggle-only chevron and a select-only label with expandOnClick=false.
tree/rtl
dir="rtl" hierarchy where ArrowLeft expands and enters branches and ArrowRight collapses or moves to the parent.