Tree select
vig-tree-select
import { TreeSelect } from '@vigdx/ui/tree-select';Basic
TreeNode objects as vig-tree takes. In single mode (the default) a click or Enter picks a node and closes the panel; [(value)] holds [key] , or [] when cleared. Opening the panel reveals the selected node.
Value: [ "de" ]
Several values
multiple toggles nodes and checkbox checks whole branches (tri-state, with cascade ); the panel stays open. The trigger shows the labels comma-separated or as removable chips ( display="chip" ), a fully checked branch as its top node, and selectedItemsLabel above maxSelectedLabels . filter adds a search field; typing on the closed field starts the search, and virtual keeps large trees fast. Disabled values keep their state: their chips have no remove button and clearing leaves them. A key whose node is not loaded (yet) shows keyLabel(key) , else the key itself; such keys stay when an ancestor is unchecked, since the field cannot tell they lie below it.
Signal Forms
[formField] : errors, required, disabled and touched state come from the form. An array field expresses “at least one” with minLength .
Pick at least one.
Reactive Forms
VigValueAccessor next to the field for formControlName , formControl and ngModel . A reset writes [] .
Styling hooks
Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="tree-select"][data-part="field"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.
Scope: [data-scope="tree-select"]
| Part | Element | data-state |
|---|---|---|
field | — | |
label | — | |
trigger | role="combobox" element. | open, closed |
value | — | |
chip | vig-chip per shown value ( display="chip" ). | — |
placeholder | — | |
indicator | — | |
clear | clearable ). | — |
panel | role="dialog" panel, in the overlay container; the tree in it keeps the Tree parts. | — |
filter | filter ). | — |
hint | vig-hint (a display: contents host; style its text part). | — |
disabled-reason | vig-hint with the disabled reason ( display: contents ). | — |
error | vig-field-error (a display: contents host; style its message part). | — |
| Attribute | Meaning |
|---|---|
data-opening | <dialog> ) while its entrance transition plays; removed once it settles (2s at most). Style the entrance with data-opening: utilities. |
data-closing | data-closing: utilities. |
Accessibility
- The trigger is a
role="combobox"labelled by the field label, witharia-haspopup="dialog"andaria-expanded; its panel is arole="dialog"named like the field, holding the search field and avig-treewith all of its keyboard support. - ArrowDown, ArrowUp, Enter or Space open the panel and move focus to the selected node (or the first one), or to the search field with
filter; ArrowDown in the search field moves on to the tree. Escape closes the panel and returns focus to the trigger; Tab closes it and moves on from the trigger. - Texts are translated with the locale or per instance through
labels(clearAriaLabel,removeAriaLabel,filterAriaLabel,selectedItemsLabeland the tree's loading, error and empty texts).
API
TreeSelect
vig-tree-selectA form field whose panel holds a vig-tree: pick one node (single),
several (multiple), or check whole branches (checkbox). The value is
always an array of node keys, so switching mode never changes its type and
it survives reloading the data. Several values show as text or chips
(display), and filter adds a search field above the tree.
<vig-tree-select label="Category" [nodes]="categories" [formField]="form.category" />The trigger is a combobox opening a dialog (aria-haspopup="dialog"):
focus moves into the tree (or its search field), Escape closes it and
returns to the trigger. Works with Signal Forms and, through
VigValueAccessor, with Reactive Forms and ngModel.
While it plays its entrance or exit transition, the animating element
carries data-opening or data-closing (stable hooks for styling and
for waiting in tests; see the theming guide).
data-opening data-closing
| Name | Type | Default | Description |
|---|---|---|---|
cascade | boolean | true |
|
clearable | boolean | false | Shows a button that clears the value while one is set. |
dirty | boolean | false | — |
disabled | boolean | false | — |
disabledReasons | readonly WithOptionalFieldTree<DisabledReason>[] | [] | — |
display | "comma" | "chip" | 'comma' | Several values: |
errorMessages | Record<string, string> | — | — |
errors | readonly ValidationError.WithOptionalFieldTree[] | [] | — |
filter | boolean | false | Adds a search field above the tree; matches show with their ancestors. |
hidden | boolean | false | — |
hideLabel | boolean | false | Visually hides the label, which still names the field; pair it with a placeholder. |
hint | string | undefined | undefined | — |
invalid | boolean | false | — |
keyLabel | ((key: string) => string | undefined) | undefined | undefined | Labels a selected key whose node is not known: not loaded yet (under a
lazy node) or gone from |
label | string | — | — |
labelPosition | LabelPosition | 'float' |
|
labels | Partial<TreeSelectLabels> | — | Texts (i18n); locale defaults. |
loadChildren | TreeLoader<T> | undefined | undefined | Fetches the children of nodes that have none of their own; see |
maxSelectedLabels | number | 3 | Above this many values the trigger shows |
name | string | '' | — |
nodes | readonly TreeNode<T>[] | [] | The top-level nodes. |
pending | boolean | false | — |
placeholder | string | undefined | undefined | Shown in the trigger while nothing is selected. |
readonly | boolean | false | — |
required | boolean | false | — |
selectionMode | TreeSelectMode | 'single' |
|
size | FieldSize | 'md' | — |
touched | boolean | false | — |
value | readonly string[] | [] | Keys of the selected nodes; empty when nothing is selected. |
virtual | boolean | false | Renders only the rows in view in the panel's tree, for large trees (see |
| Name | Payload | Description |
|---|---|---|
touch | void | — |
valueChange | readonly string[] | Keys of the selected nodes; empty when nothing is selected. |
| Signature | Description |
|---|---|
focus(options?: FocusOptions): void | Moves focus to the control's interactive element (the input, or the
trigger of a popup control). Signal Forms calls it through
|
reset(): void | Closes the panel without moving focus or marking the field touched; see |