Skip to main content
Neural Nativev0.1.0-beta.1Documentation

Import

component.ts
import { NeuTreeComponent } from '@neural-ui/native/tree';

Examples

Import ExampleComponent into its parent and place <app-example /> inside your application’s root neu-theme. The preview supplies the device frame and safe areas; use the root setup from Installation in your app.

Inside the project

Expand folders and choose real file names. A small file summary changes with the selected document while the tree retains its structure.

View and copy the complete example
basic.component.ts
import { Component, signal, computed } from '@angular/core';
import { NeuTreeComponent } from '@neural-ui/native/tree';
import { View, Text, ScrollView } from '@ng-native/components';
import type { NeuTreeNode } from '@neural-ui/native';

@Component({
  selector: 'app-example',
  imports: [NeuTreeComponent, View, Text, ScrollView],
  template: `
    <scroll-view class="product-scroll" keyboardShouldPersistTaps="handled" [showsVerticalScrollIndicator]="true"><view class="product-stack"><view class="product-section"><text class="product-title" accessibilityRole="header">Inside the project</text><text class="product-caption">Browse the files that shape your workspace</text></view>
    <view class="product-surface"><neu-tree label="Project files" [nodes]="files" [(expanded)]="expanded" [(value)]="selectedFile" [leafOnly]="true" /></view>
    <view class="product-surface"><text class="product-heading">File preview</text><text class="product-caption">{{ selectedFile() }}</text><text>{{ preview() }}</text></view></view></scroll-view>
  `,
  styles: `
.actions { gap: 12px; align-items: flex-start; } text { color: var(--neu-text, #172033); font-size: 16px; }

:host { flex: 1; flex-shrink: 1; min-height: 0; }
.product-scroll { flex: 1; flex-shrink: 1; height: 0px; min-height: 0; }
.product-stack { gap: 24px; padding-bottom: 20px; }
.product-section { gap: 12px; }
.product-row { flex-direction: row; align-items: center; gap: 12px; }
.product-copy { flex: 1; min-width: 0; gap: 4px; }
.product-title { color: var(--neu-text, #172033); font-size: 24px; line-height: 30px; font-weight: 600; }
.product-heading { color: var(--neu-text, #172033); font-size: 17px; line-height: 23px; font-weight: 600; }
.product-caption { color: var(--neu-muted, #596477); font-size: 14px; line-height: 20px; }
.product-actions { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
.product-surface { gap: 16px; padding: 16px; border-radius: 16px; background-color: var(--neu-surface, #ffffff); border-width: 1px; border-color: var(--neu-border, #a5afbf); }

  `,
})
export class ExampleComponent {
  readonly files: readonly NeuTreeNode[] = [
    { id: 'src', label: 'src', children: [
      { id: 'components', label: 'components', children: [{ id: 'src/components/input.ts', label: 'input.ts' }, { id: 'src/components/button.ts', label: 'button.ts' }] },
      { id: 'src/app.ts', label: 'app.ts' },
      { id: 'src/theme.css', label: 'theme.css' },
    ] },
    { id: 'README.md', label: 'README.md' },
  ];
  readonly expanded = signal<readonly string[]>(['src', 'components']);
  readonly selectedFile = signal('src/components/input.ts');
  readonly preview = computed(() => this.selectedFile().endsWith('.css') ? 'Shared colors and spacing for the workspace.' : this.selectedFile().endsWith('.md') ? 'Project setup, contribution guide and useful links.' : 'A standalone Angular component for the mobile experience.');
}
Interactive playground

Change the settings and try the result.

Device captures shown in English.

Tree · android · native capture
AndroidNative screenshot
Tree · ios · native capture
iOSNative screenshot

API reference

Inputs

NameTypeDefaultBindingDescription
labelstring'Tree'InputHuman-readable name for the control, action or group.
nodesreadonly NeuTreeNode[][]InputHierarchical nodes with optional children. Keep IDs unique across the whole tree.
disabledbooleanfalseInputDisables user interaction. Values can still be supplied by the application.
readonlybooleanfalseInputPrevents user editing or selection while retaining the current value.
leafOnlybooleanfalseInputRestricts selectable values to leaf nodes; parent nodes still organize the hierarchy.
expandLabelstring'Expand'InputText or accessible name used for expand. It does not perform the action by itself.
emptyLabelstring'No items'InputText or accessible name used for empty state. It does not perform the action by itself.

Models

NameTypeDefaultBindingDescription
expandedreadonly string[][]Model · two-wayIDs of currently expanded sections or nodes. Bind a writable signal with [(expanded)].
valuestring''Model · two-wayCurrent edited value or selected ID(s), using the declared type. Bind a writable signal with [(value)].

Outputs

NamePayloadWhen it emits
expandedChangereadonly string[]Emits the updated expanded value. [(expanded)] binds this output together with its model input.
valueChangestringEmits the updated value value. [(value)] binds this output together with its model input.
selectedstringEmits the selected item ID.
touchvoidReports user interaction to the surrounding form or application.

Model state

Bind the signal with [(modelName)] without calling it. Use modelName() to read its value.

model-fields.ts
import { signal } from '@angular/core';

// Fields inside your component class
readonly expanded = signal<readonly string[]>([]);
readonly value = signal<string>('');

Types and data interfaces

Use the imports in your application. The definitions below are provided for reference.

NeuOption

NeuOption.ts
import type { NeuOption } from '@neural-ui/native';

// Public definition for reference only. Import this type; do not redeclare it.
export interface NeuOption {
    readonly id: string;
    readonly label: string;
    readonly description?: string;
    readonly disabled?: boolean;
}
FieldTypeRequirementMeaning
idstringRequiredStable, unique identifier used for tracking and selection.
labelstringRequiredHuman-readable item name.
descriptionstringOptionalOptional supporting text; rendering depends on the control.
disabledbooleanOptionalPrevents activating or selecting this item.

NeuTreeNode

NeuTreeNode.ts
import type { NeuTreeNode } from '@neural-ui/native';
import type { NeuOption } from '@neural-ui/native';

// Public definition for reference only. Import this type; do not redeclare it.
export interface NeuTreeNode extends NeuOption {
    readonly children?: readonly NeuTreeNode[];
}
FieldTypeRequirementMeaning
childrenreadonly NeuTreeNode[]OptionalRecursive child nodes; omit for a leaf.
idstringRequiredStable, unique identifier used for tracking and selection.
labelstringRequiredHuman-readable item name.
descriptionstringOptionalOptional supporting text; rendering depends on the control.
disabledbooleanOptionalPrevents activating or selecting this item.