WlTreeSelect
Selection
Open the tree with Enter, Space or Arrow Down. Select one node or press Escape to return to the field. A named field submits the selected key. Use the motion prop to override the application’s animation setting for this panel.
Full example
<WlField v-slot="{ id, labelId }" label="Destination folder">
<WlTreeSelect
:id="id"
v-model="target"
:nodes="folders"
name="folder"
placeholder="Choose a folder"
:aria-labelledby="labelId"
clearable
/>
</WlField>States
Full example
<WlField v-slot="{ id, labelId }" label="Destination folder">
<WlTreeSelect
:id="id"
v-model="target"
:nodes="folders"
name="folder"
placeholder="Choose a folder"
:aria-labelledby="labelId"
clearable
/>
</WlField>Behavior
Full example
<WlField v-slot="{ id, labelId }" label="Destination folder">
<WlTreeSelect
:id="id"
v-model="target"
:nodes="folders"
name="folder"
placeholder="Choose a folder"
:aria-labelledby="labelId"
clearable
/>
</WlField>Submit a folder key
Choose a folder and save the form to see the key received by FormData. Clear the field and repeat to submit an empty selection.
Full example
<script setup lang="ts">
import { WlButton, WlField, type WlTreeKey, type WlTreeNode, WlTreeSelect } from "legato-ui";
import { computed, ref } from "vue";
const selected = ref<WlTreeKey | null>(null);
const submitted = ref<string | null>(null);
const folders = computed<readonly WlTreeNode[]>(() => [
{ key: "materials", label: "Materials", children: [
{ key: "design", label: "Design" },
{ key: "brief", label: "Brief" }
] }
]);
function submit(event: Event): void {
if (event.currentTarget instanceof HTMLFormElement) {
submitted.value = String(new FormData(event.currentTarget).get("folder") ?? "");
}
}
</script>
<template>
<form class="wl-stack" data-space="sm" @submit.prevent="submit">
<WlField v-slot="{ id, labelId }" label="Destination folder">
<WlTreeSelect
:id="id"
v-model="selected"
:nodes="folders"
placeholder="Choose a folder"
:aria-labelledby="labelId"
name="folder"
clearable
/>
</WlField>
<div><WlButton type="submit">{{ "Save folder" }}</WlButton></div>
<output v-if="submitted !== null" aria-label="Submitted folder key">
{{ submitted || "No folder selected" }}
</output>
</form>
</template>Props
Types, accepted values and literal defaults come from the public manifest. Inherited settings name their source; “Not set” means no default is declared.
v-model: WlTreeKey |Selected node key, or null when no node is selected.
| Prop | Type / values | Default | Purpose |
|---|---|---|---|
nodes * | readonly WlTreeNode[] | Required | Nested choices with unique keys. |
placeholder | string | Not set | Text shown before a choice is made. |
clearable | boolean | Not set | Offer a separate clear action. |
disabled | boolean | Not set | Prevent interaction and exclude the value from form submission. |
invalid | boolean | Not set | Expose a validation error on the trigger. |
name | string | Not set | Name of the submitted form value. |
form | string | Not set | ID of the associated native form when mounted outside it. |
motion | boolean | Inherits WlConfig.motion | Animate the panel. Defaults to WlConfig.motion. |
pt | WlPt< | Not set | Attributes of the trigger, display and overlay. |
Events
| Event | Payload | When emitted |
|---|---|---|
update:modelValue | WlTreeKey | | The new selected key, or null after clearing the field. |
update:expandedKeys | readonly WlTreeKey[] | The updated keys of expanded branches. |
Slots
| Slot | Type / values | Content |
|---|---|---|
node | node?(props: WlTreeNodeSlotProps): unknown; | Customize the non-interactive content of a tree row. |
empty | empty?(): unknown; | Content when there are no choices. |
Pass-through: pt
Sections WlTreeSelect are listed below. Attributes merge in this order: createWlPt() WlConfig.ptpt instance. Class and style merge; the last supplied value takes priority for other attributes.
| Section | DOM | Purpose |
|---|---|---|
root | div.wl-tree-select | Main element of the component. |
trigger | button.wl-tree-select__trigger | Button that opens the overlay. |
label | span.wl-tree-select__label | Displayed text label. |
indicator | svg | Decorative disclosure icon. |
clear | button.wl-tree-select__clear | Button that clears the value. |
panel | div.wl-tree-select__panel | Panel that contains the current content. |
tree | div.wl-tree | Tree used to choose a node. |
Sections refer to the component DOM. Dotted names identify a configuration group and its section; composite parts use their own pt groups. Global and local attributes merge, with class and style added together.
Keyboard and accessibility
- Open the tree with Enter, Space or Arrow Down. Select one node or press Escape to return to the field. A named field submits the selected key. Use the motion prop to override the application’s animation setting for this panel.
- Associate a label with the trigger using WlField or aria-labelledby.
- Escape closes the tree and returns focus to the trigger. Use the clear action to reset the chosen key.
Keyboard and application responsibilities
Provide a meaningful accessible name and connect labels, hints and errors to the focusable element. Check the behavior with your own data and a screen reader.
WAI-ARIA Authoring PracticesChanges are emitted through v-model. After selection, cancellation and reset, labels and states must remain clear.
In your application, check keyboard controls, zoom and focus visibility. State labels and required information must be readable in every theme.