Skip to main content
Neural UIv2.0.0Documentation
View v1 GitHub

TreeSelect

Choose nodes in a hierarchy with controlled expansion and single or multiple selection.

Category
Forms and selection
Import
@neural-ui/core/tree-select
Selector
neu-tree-select
import { NeuTreeSelectComponent } from '@neural-ui/core/tree-select';

Usage

TreeSelect keeps the hierarchy visible in its panel. Single mode stores one node value; multiple mode stores an array. Independent selection affects only the chosen node; propagated selection follows parent/child relationships.

Expansion is controlled: bind expandedKeys and apply expandedKeysChange. For lazy nodes, childrenRequest asks the application to supply child records; it does not fetch them itself.

Signal Forms

Bind FormField to the value-owning control and add required to the form schema. Select a destination, leave the field to mark it touched, and reset it to check both value and validation state. A required marker on its own does not validate your form.

Signal Forms guide

Signal Forms

Value: โ€” ยท Valid: false

Try and configure

Change the settings below and interact with the live control. The preview, current application value and generated template stay together. A disabled destination lets you check that unavailable choices cannot be selected.

Try and configure
Live preview

Events: 0 ยท

Generated template: reflects the settings above. Imports and state are in the Code tab.

template.html
<neu-tree-select
  (opened)="record('opened', $event)"
  (closed)="record('closed', $event)"
  (nodeExpanded)="record('nodeExpanded', $event)"
  (nodeCollapsed)="record('nodeCollapsed', $event)"
  (childrenRequest)="loadChildren($event)"
  (rangeChange)="record('rangeChange', $event)"
  (filter)="record('filter', $event)"
  (cleared)="record('cleared', $event)"
  (touch)="record('touch', $event)"
  (valueChange)="record('valueChange', $event)"
  [nodes]="destinations"
  [(value)]="destination"
  [expandedKeys]="expandedKeys()"
  (expandedKeysChange)="expandedKeys.set($event)"
  [clearable]="true"
  [emptyLabel]="'No destinations'"
  [label]="'Destination'"
  [placeholder]="'Choose a destination'"
  [searchPlaceholder]="'Search destinations'"
/>

Value and events

Use one source of truth: [(value)]="destination" or [value]="destination()" with (valueChange)="destination.set($event)". Do not bind both forms at once.

Inputs configure the control. valueChange synchronizes its model; the other Outputs report their documented actions or lifecycle. Requests for suggestions, children or remote windows require the application to supply data.

Accessibility and keyboard

Use a visible label or an accessible name. Test keyboard navigation, disabled options, selection and closing the panel. Custom option templates should keep descriptive text and must not introduce a nested button or another focusable checkbox inside the option.

Key
Action
Tab Moves focus into or out of the control.
ArrowDown / ArrowUp Moves the active option through available options.
Enter Activates the focused option.
Escape Closes the panel without selecting another option.

API

The reference lists the public Inputs, models, Outputs and Templates from the pinned Core package. Click a named type to open its definition. Each applicable Template has an executable example and its actual source.

Inputs

Configure the component with [property]="value". Your application supplies these values; the component does not replace the state you pass in.

Name
Type
Default
Template binding
Description
clearablebooleanfalse[clearable]Shows a clear action when a value is selected.
clearLabelstring'Clear selection'[clearLabel]Label for the clear-selection action.
disabledbooleanfalse[disabled]Disables user interaction; disabled options cannot be selected.
emptyLabelstring'No options found'[emptyLabel]Message displayed when there are no available options.
expandedKeysreadonly V[][][expandedKeys]Applied node expansion keys. Accept expandedKeysChange by updating this input.
labelstring''[label]Visible field or option label.
modeM'single' as MDerived default[mode]Selection mode. The accepted value shape follows the chosen mode.
nodesreadonly T[][][nodes]Root node records. Child relationships come from optionChildren.
optionChildrenNeuOptionAccessor<T, readonly T[]> | nullnull[optionChildren]Field name or function that reads a node's children.
optionDisabledNeuOptionDisabledAccessor<T> | nullnull[optionDisabled]Field name or function that marks an option as disabled.
optionLabelNeuOptionLabelAccessor<T> | nullnull[optionLabel]Field name or function used to obtain the visible option label.
optionValueNeuOptionValueAccessor<T, V> | nullnull[optionValue]Field name or function used to obtain the stored option value.
placeholderstring'Select...'[placeholder]Text shown when the field has no selected value.
readonlybooleanfalse[readonly]Keeps the value readable without allowing the user to change it.
searchablebooleantrue[searchable]Displays the built-in option search field.
searchPlaceholderstring'Search...'[searchPlaceholder]Placeholder for the option search field.
selectionStrategyNeuTreeSelectSelectionStrategy'independent'[selectionStrategy]Independent node selection or propagation through parent/child relationships.
touchedbooleanfalse[touched]Form state indicating that the control has been visited.
virtualizationOptionsReadonly<NeuTreeSelectVirtualizationOptions>{}[virtualizationOptions]Tree viewport settings: enabled, itemSize, viewportHeight and buffer.

Models

A model supports [(property)]="signal" or the [property] and (propertyChange) pair. Choose one form, not both.

Name
Type
Default
Template binding
Description
valueNeuSelectionValue<V, M>null as NeuSelectionValue<V, M>Derived default[(value)]Single mode: one value or null. Multiple mode: an array. The application owns the bound model.

Outputs

Listen to an event with (event)="handler($event)". The table explains the data your handler receives and how to use it.

Name
Payload
Template binding
Description
childrenRequestNeuTreeSelectChildrenRequest<V>(childrenRequest)="onChildrenRequest($event)"Requests children for a lazy node; update the loaded node data when ready.
clearedvoid(cleared)="onCleared($event)"Emitted for the explicit clear action; valueChange carries the resulting value.
closedvoid(closed)="onClosed($event)"Emitted after the browser panel closes.
expandedKeysChangereadonly V[](expandedKeysChange)="onExpandedKeysChange($event)"Proposed expansion keys. Update expandedKeys to apply the change.
filter{ query: string; }(filter)="onFilter($event)"Changed raw search query from user input.
nodeCollapsedT(nodeCollapsed)="onNodeCollapsed($event)"Node collapsed by a user action.
nodeExpandedT(nodeExpanded)="onNodeExpanded($event)"Node expanded by a user action.
openedvoid(opened)="onOpened($event)"Emitted after the browser panel opens.
rangeChangeNeuViewportRange(rangeChange)="onRangeChange($event)"Current visible virtual viewport range.
touchvoid(touch)="onTouch($event)"Notifies the form that the control has been touched; not a value change.

Templates

ng-content projects content into the component. TemplateRef inputs receive a template; ng-template directives identify templates with a typed context. A directive shared by an entrypoint is not necessarily a slot of this component.

Name
Mechanism
Contract
NeuTreeSelectEmptyDirectiveView example Public template directive (entrypoint)ng-template[neuTreeSelectEmpty]
NeuTreeSelectFooterDirectiveView example Public template directive (entrypoint)ng-template[neuTreeSelectFooter]
NeuTreeSelectHeaderDirectiveView example Public template directive (entrypoint)ng-template[neuTreeSelectHeader]
NeuTreeSelectNodeDirectiveView example Public template directive (entrypoint)ng-template[neuTreeSelectNode]
NeuTreeSelectSelectedDirectiveView example Public template directive (entrypoint)ng-template[neuTreeSelectSelected]

Each example demonstrates a different template. Switch between Demo and Code to inspect its implementation, imports and state.

Empty template

NeuTreeSelectEmptyDirective

Empty template

Open the control to see the empty state.

Header template

NeuTreeSelectHeaderDirective

Header template

Open the control to see the custom template.

Node template

NeuTreeSelectNodeDirective

Node template

Open the control to see the custom template.

Selected template

NeuTreeSelectSelectedDirective

Selected template

Open the control to see the custom template.

Public Types

Open a type to inspect its definition and interface fields.

Styles and tokens

Load Core styles once. Use the public tokens below for local customization or a preset for application-wide changes. Keep labels, focus, selected options and disabled states readable in both light and dark themes.

Specific tokens

This component uses shared theme tokens rather than dedicated component hooks.

Shared tokens used

Override these on a local wrapper to affect this example. An override on :root affects other components that use the same token.

Token
Purpose here
Other impact
Default / fallback
--neu-border Normal control and cell borders Shared by other Core consumers; scope the override. rgba(15, 23, 42, 0.08)
--neu-focus-ring Normal keyboard-focus ring Shared by other Core consumers; scope the override. 0 0 0 var(--neu-focus-ring-width) rgba(0, 122, 255, 0.15)
--neu-primary Brand color for active controls and emphasis Shared by other Core consumers; scope the override. #007aff
--neu-radius Control corner radius Shared by other Core consumers; scope the override. 8px
--neu-surface Main field, header or control surface Shared by other Core consumers; scope the override. #ffffff
--neu-text Main text and inherited icon color Shared by other Core consumers; scope the override. #0f172a
--neu-text-muted Secondary labels and supporting content Shared by other Core consumers; scope the override. #475569
--neu-shadow-lg Surface or overlay elevation Shared by other Core consumers; scope the override. 0 10px 30px rgba(15, 23, 42, 0.1), 0 4px 8px rgba(15, 23, 42, 0.04)