# Select

**Select inputs** are fields that allow users to choose options from a menu.

## Usage

Element offers two distinct select input types: the Default Select and the Advanced Select.

The **default select** is based on the native HTML `select` element. Use it for straightforward scenarios where users need to select a single option from a dropdown list.

The **advanced select** is designed to accommodate more complex requirements, offering support for single-selection, multi-selection, icons, and a search function. This variant should be employed only when one or more of the mentioned capabilities are necessary.

![Select input field](<../images/select-input.png>)

### When to use

- When users need to make a choice among a list of options.
- When there are more than 5 options to choose from.
- When options can be logically grouped (e.g., countries, cities, etc.).
- Use it in forms and for attribute selection.

### Best practices

- Don't use it if there are less than three options available for selection.
- Analyze what actions will save more time for the user (e.g. selecting an item versus typing that item).
- If possible, mark the default option as the recommended one (avoid extra clicking).

## Design

### Default select

![Select input](<../images/select-input-elements.png>)

> 1.Label (optional), 2. Content/placeholder text, 3. Container, 4. Arrow

### Advanced select

![Select input advanced](<../images/select-advanced.png>)

> Label (optional) 2. Content/placeholder text, 3. Container, 4. Arrow, 5. Icon (optional), 6. Menu

Advanced select supports both single and multiple selections. When dealing with many options, a filterable menu with a search bar can be used to streamline selection.

![Select input advanced menu](<../images/select-advanced-selection.png>)

Selected options are displayed within the input field. If they exceed the available space, they will be grouped into a single pill (e.g. using 3+).

![Select input advanced responsive](<../images/select-advanced-responsive.png>)

### States

Advanced select provides two configurations: Inline for direct integration with content, and form-style for structured data entry.

![Select input states](<../images/select-states.png>)

### Label (optional)

Effective form labeling helps users understand what information to enter.

- Keep labels short and clear (should not be wider than the input field).
- A mandatory field is marked with an **\*-asterisk**.

![Select input label](<../images/select-input-label.png>)

### Validation

The select input field has the same validation states as a [input component](<https://element.siemens.io/components/forms-inputs/input/>).

## Code

### References

- **Bootstrap:** [Select](<https://getbootstrap.com/docs/5.1/forms/select/>)

### Example

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { Component } from '@angular/core';

@Component({
  selector: 'app-sample',
  templateUrl: './select.html',
  host: { class: 'p-5' }
})
export class SampleComponent {
  validation = false;
}
```

Template:

```html
<h3>Select</h3>
<form [class.was-validated]="validation">
  <div class="position-relative">
    <select aria-label="number" class="form-select" [required]="validation">
      <option value="">Open this select menu</option>
      <option value="1">One</option>
      <option value="2">Two</option>
      <option value="3">Three</option>
    </select>
    <div class="invalid-feedback">Example invalid feedback text</div>
    <div class="valid-feedback">Example valid feedback text</div>
  </div>
  <p></p>
  <div class="position-relative">
    <select aria-label="number" class="form-select" disabled [required]="validation">
      <option value="">Disabled</option>
      <option value="1">One</option>
      <option value="2">Two</option>
      <option value="3">Three</option>
    </select>
    <div class="invalid-feedback">Example invalid feedback text</div>
    <div class="valid-feedback">Example valid feedback text</div>
  </div>
  <p></p>
  <div class="position-relative">
    <select aria-label="number" class="form-select" multiple [required]="validation">
      <option value="">Multiselect</option>
      <option value="1">One</option>
      <option value="2">Two</option>
      <option value="3">Three</option>
    </select>
    <div class="invalid-feedback">Example invalid feedback text</div>
    <div class="valid-feedback">Example valid feedback text</div>
  </div>
  <p></p>
  <div class="position-relative">
    <select aria-label="number" class="form-select" multiple disabled [required]="validation">
      <option value="">Disabled multiselect</option>
      <option value="1">One</option>
      <option value="2">Two</option>
      <option value="3">Three</option>
    </select>
    <div class="invalid-feedback">Example invalid feedback text</div>
    <div class="valid-feedback">Example valid feedback text</div>
  </div>
</form>

<hr />
<h3 class="mt-8">Configuration</h3>
<div class="mx-4">
  <div class="form-check form-check-inline">
    <input
      type="checkbox"
      class="form-check-input"
      id="validationCheckbox"
      [checked]="validation"
      (change)="validation = !validation"
    />
    <label class="form-check-label" for="validationCheckbox">Simulate validation</label>
  </div>
</div>
```

### si-select component

Element also offers a custom select component called `si-select`. The `si-select` component provide the following abilities:

- specify the icon for each specified option.
- disable options
- single / multi-select behavior
- custom option input
- option groups
- customizable rendering of options
- option filtering
- customizable footer with actions

The component should only be used if you require one of the listed abilities. Otherwise the [native select input with Bootstrap markup](<https://element.siemens.io/components/forms-inputs/select/#code>) is preferred.

#### Usage

`si-select` can be imported using the module

```
import { SiSelectModule } from '@siemens/element-ng/select';

@NgModule({
  imports: [SiSelectModule, ...]
})
```

or as a standalone component:

```
import {
  SiSelectComponent,
  SiSelectSimpleOptionsDirective, // At least one option directive is required. Unused option types can be omitted.
  SiSelectSingleValueDirective, // At least one value directive is required. Unused value types can be omitted.
  SiSelectMultiValueDirective
} from '@siemens/element-ng/select';

@Component({
  imports: [
    SiSelectComponent,
    SiSelectSimpleOptionsDirective,
    SiSelectSingleValueDirective,
    SiSelectMultiValueDirective,
  ]
})
```

### Options

Options are provided as an array of `SelectItem<T>` objects:

```
<si-select
  [options]="[
    {
      type: 'option',
      value: { id: id, myProperty: myValue },
      label: 'Label',
      disabled: false,
      icon: 'element-face-happy',
      iconColor: 'status-success'
    }
  ]"
/>
```

Customize option rendering using a template. This template is used for options in the dropdown and, when no input template is provided, for the selected value in the closed input as well:

```
<si-select
  [options]="[
    { type: 'option', value: 'good', label: 'Good' },
    { type: 'option', value: 'fair', label: 'Fair' },
    { type: 'option', value: 'bad', label: 'Bad' }
  ]"
>
  <ng-template let-option siSelectOptionTemplate>{{ option.label | uppercase }}</ng-template>
</si-select>
```

To use different templates for the dropdown options and the selected value in the closed input, provide an additional `siSelectValueTemplate` template. Both templates receive the `SelectOption<T>` as their implicit value:

```
<si-select [options]="options">
  <ng-template let-option siSelectOptionTemplate>
    <div class="d-flex flex-column">
      <span>{{ option.label }}</span>
      <small class="text-secondary">Additional information</small>
    </div>
  </ng-template>
  <ng-template let-option siSelectValueTemplate>{{ option.label }}</ng-template>
</si-select>
```

Wrap options in groups:

```
<si-select
  [options]="[
    {
      type: 'group',
      label: 'Group',
      options: [{ type: 'option', label: 'Option', value: 'value' }]
    }
  ]"
>
  <!-- Optional group template -->
  <ng-template let-group siSelectGroupTemplate>{{ group.label | uppercase }}</ng-template>
</si-select>
```

### Lazy options

Instead of providing eagerly loaded options, applications can provide an `[optionSource]`. The option source allows lazy loading of options. It can be used with or without filtering.

To use the `[optionSource]` applications must implement the `SelectOptionSource` interface:

```
// This provides options which value are of type MyValue.
// For async methods the si-select will show a loading spinner until the observable emits the first time.
// Always return options in a consistent order.
export class MyOptionSource implements SelectOptionSource<MyValue> {
  getOptionsForValues(values: MyValue[]): Observable<SelectOptionNext<MyValue>[]> {
    // si-select will call this function when it needs to get options for the provided values.
    // This function is typically called when the value is set via a formControl or ngModel.
    // Lookup the values on your server and return the corresponding options.
  }

  getAllOptions?(): Observable<SelectItem<MyValue>[]> {
    // This function is optional, if filtering is enabled.
    // The options returned by this function are shown in the dropdown when no search value is provided.
    // You can return all available options or just a subset of the most common options.
    // If this function is not implemented only the selected options are shown.
  }

  getOptionsForSearch?(search: MyValue): Observable<SelectItem<MyValue>[]> {
    // This function is required if filtering is enabled.
    // It is never called with an empty search value.
    // Return all options that matches the search value.
  }

  compareOptions?(a: SelectOptionNext<MyValue>, b: SelectOptionNext<MyValue>): number {
    // This function is optional.
    // If provided it is used to compare options for sorting.
    // This ensures a correct order if options are loaded from the cache.
  }

  optionsEqual?(optionA: MyValue, optionB: MyValue): boolean {
    // By default si-select checks values on equality by reference.
    // If you use objects as values override this method so that equal values are recognized as such.
    // For primitiv values like strings this method should be omitted.
  }
}
```

Then use this source in your component:

```
import {
  SiSelectComponent,
  SiSelectSingleValueDirective,
  SiSelectLazyOptionsDirective
} from '@siemens/element-ng/select';

@Component({
  selector: 'app-sample',
  template: '<si-select [optionSource]="myOptionSource" [formControl]="control" />',
  imports: [SiSelectComponent, SiSelectSingleValueDirective, SiSelectLazyOptionsDirective]
})
export class SampleComponent {
  myOptionSource = new MyOptionSource();
  control = new FormControl<MyValue | null>(null);
}
```

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { Component, inject, Injectable } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { SiFormItemComponent } from '@siemens/element-ng/form';
import {
  SelectItem,
  SelectOption,
  SelectOptionSource,
  SiSelectComponent,
  SiSelectLazyOptionsDirective,
  SiSelectMultiValueDirective
} from '@siemens/element-ng/select';
import { LOG_EVENT } from '@siemens/live-preview';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';

import { Country, CountryService } from './country.service';

@Injectable({ providedIn: 'root' })
class CountryOptionSource implements SelectOptionSource<string> {
  private countryService = inject(CountryService);

  getOptionsForValues(keys: string[]): Observable<SelectOption<string>[]> {
    return this.countryService
      .getCountries(keys)
      .pipe(map(countries => this.countriesToOption(countries)));
  }

  getOptionsForSearch(search: string): Observable<SelectItem<string>[]> {
    return this.countryService
      .searchCountries(search.toLowerCase())
      .pipe(map(countries => this.countriesToOption(countries)));
  }

  compareOptions(a: SelectOption<string>, b: SelectOption<string>): number {
    return a.label!.localeCompare(b.label!);
  }

  private countriesToOption(countries: Country[]): SelectOption<string>[] {
    return countries.map(country => ({
      value: country.code,
      label: `${country.code} - ${country.name}`,
      type: 'option'
    }));
  }
}

@Component({
  selector: 'app-sample',
  imports: [
    FormsModule,
    SiFormItemComponent,
    SiSelectComponent,
    SiSelectMultiValueDirective,
    SiSelectLazyOptionsDirective
  ],
  templateUrl: './si-select-lazy-load.html',
  styles: 'si-select { max-inline-size: 300px}',
  host: { class: 'p-5' }
})
export class SampleComponent {
  readonly logEvent = inject(LOG_EVENT);
  readonly optionSource = inject(CountryOptionSource);
  readonly = false;
  disabled = false;
  value: string[] = ['DE'];

  selectionChanged(value: string[]): void {
    this.logEvent('Selection:', this.value);
  }
}
```

Template:

```html
<div class="p-5 background-1">
  <h4>
    <span id="lazy-options">Lazy options</span>
  </h4>
  <si-select
    multi
    labelledby="lazy-options"
    class="form-control"
    hasFilter
    [optionSource]="optionSource"
    [disabled]="disabled"
    [readonly]="readonly"
    [(value)]="value"
    (valueChange)="selectionChanged($event)"
  />
</div>

<div class="card mt-6 e2e-ignore">
  <div class="card-header">Control panel</div>
  <div class="card-body">
    <div class="mb-6"> Current value: {{ value }} </div>
    <div class="mb-6">
      <si-form-item class="form-switch" label="Readonly">
        <input type="checkbox" class="form-check-input" [(ngModel)]="readonly" />
      </si-form-item>
      <si-form-item class="form-switch" label="Disabled">
        <input type="checkbox" class="form-check-input" [(ngModel)]="disabled" />
      </si-form-item>
    </div>
  </div>
</div>
```

#### Selection

Single selection:

```
@Component({
  selector: 'app-sample',
  imports: [SiSelectComponent, SiSelectSimpleOptionsDirective, SiSelectSingleValueDirective],
  template: '<si-select [options]="optionsList" [(value)]="selected" />'
})
export class SampleComponent {
  optionsList: SelectItem<string>[] = [
    {
      type: 'option',
      value: 'good',
      label: 'Good'
    },
    {
      type: 'option',
      value: 'fair',
      label: 'Fair'
    }
  ];
  selected = 'good';
}
```

Multi selection:

```
@Component({
  selector: 'app-sample',
  imports: [SiSelectComponent, SiSelectSimpleOptionsDirective, SiSelectMultiValueDirective],
  template: '<si-select multi [options]="optionsList" [(value)]="multiValue" />'
})
export class SampleComponent {
  optionsList: SelectItem<string>[] = [
    { type: 'option', value: 'good', label: 'Good' },
    { type: 'option', value: 'fair', label: 'Fair' }
  ];
  multiValue = ['good', 'fair'];
}
```

#### Filtering options

Add the attribute `hasFilter` to enable an input element for option filtering in the overlay of the `si-select` component. If a custom template is used, a value provider is required.

```
<si-select hasFilter [options]="[...]" />
```

#### Footer actions

By using the `siSelectActions` directive, you can add custom actions to the footer of the `si-select` component.

To align the styling to the design system specification it is necessary that actions:

- apply the `siSelectAction` directive to each item
- and footer buttons shall apply the following classes `btn btn-link`.

```
<si-select [options]="[{ id: 'option1', title: 'Option 1' }, { id: 'option2', title: 'Option 2' }]">
  <ng-template siSelectActions>
    <button siSelectAction type="button" class="btn btn-link" aria-label="Action 1">
      Action 1
    </button>
    <button siSelectAction type="button" class="btn btn-link" aria-label="Action 2">
      Action 2
    </button>
  </ng-template>
</si-select>
```

In some scenarios it is necessary to close the dropdown on click for example to display a modal dialog. The `siSelectActions` directive offers an input `selectActionAutoClose` for this purpose.

The following demonstrates how to add a "Create" button within the dropdown actions that, when clicked, will close the dropdown:

```
<si-select [options]="[{ id: 'option1', title: 'Option 1' }, { id: 'option2', title: 'Option 2' }]">
  <ng-template siSelectActions>
    <button siSelectAction selectActionAutoClose type="button" class="btn btn-link" (click)="....">
      Create
    </button>
  </ng-template>
</si-select>
```

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { PercentPipe, TitleCasePipe } from '@angular/common';
import { Component, inject, signal } from '@angular/core';
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
// eslint-disable-next-line no-restricted-imports
import { TranslatePipe } from '@ngx-translate/core';
import {
  SelectItem,
  SiSelectActionDirective,
  SiSelectActionsDirective,
  SiSelectComponent,
  SiSelectGroupTemplateDirective,
  SiSelectMultiValueDirective,
  SiSelectOptionTemplateDirective,
  SiSelectValueTemplateDirective,
  SiSelectSimpleOptionsDirective,
  SiSelectSingleValueDirective
} from '@siemens/element-ng/select';
import { LOG_EVENT } from '@siemens/live-preview';

@Component({
  selector: 'app-sample',
  imports: [
    FormsModule,
    PercentPipe,
    ReactiveFormsModule,
    SiSelectComponent,
    SiSelectMultiValueDirective,
    SiSelectSimpleOptionsDirective,
    SiSelectSingleValueDirective,
    SiSelectActionsDirective,
    SiSelectActionDirective,
    SiSelectOptionTemplateDirective,
    SiSelectValueTemplateDirective,
    SiSelectGroupTemplateDirective,
    TitleCasePipe,
    TranslatePipe
  ],
  templateUrl: './si-select.html',
  host: { class: 'p-5' }
})
export class SampleComponent {
  readonly logEvent = inject(LOG_EVENT);

  readonly = false;
  disabled = false;
  withFilter = false;
  value = 'fair';
  formControl = new FormControl('good');
  multiValue = ['good', 'fair'];
  groupedMultiValue = ['Value 1.1', 'Value 2.2'];

  readonly optionsList: SelectItem<string>[] = [
    {
      type: 'option',
      value: 'good',
      icon: 'element-face-happy',
      iconColor: 'status-success',
      label: 'Good'
    },
    {
      type: 'option',
      value: 'fair',
      icon: 'element-face-neutral',
      iconColor: 'status-warning',
      label: 'Fair'
    },
    {
      type: 'option',
      value: 'bad',
      icon: 'element-face-unhappy',
      iconColor: 'status-danger',
      label: 'Bad'
    },
    {
      type: 'option',
      value: 'very-bad',
      icon: 'element-face-very-unhappy',
      iconColor: 'status-critical',
      label: 'Very bad',
      disabled: true
    }
  ];

  readonly groupedOptions: SelectItem<string>[] = [
    {
      type: 'group',
      label: 'Group 1',
      options: [
        { type: 'option', value: 'Value 1.1', label: 'Value 1.1' },
        { type: 'option', value: 'Value 1.2', label: 'Value 1.2' },
        { type: 'option', value: 'Value 1.3', label: 'Value 1.3' }
      ]
    },
    {
      type: 'group',
      label: 'Group 2',
      options: [
        { type: 'option', value: 'Value 2.1', label: 'Value 2.1' },
        { type: 'option', value: 'Value 2.2', label: 'Value 2.2' },
        { type: 'option', value: 'Value 2.3', label: 'Value 2.3' }
      ]
    },
    {
      type: 'group',
      label: 'Group 3',
      options: [
        { type: 'option', value: 'Value 3.1', label: 'Value 3.1' },
        { type: 'option', value: 'Value 3.2', label: 'Value 3.2' },
        { type: 'option', value: 'Value 3.3', label: 'Value 3.3' }
      ]
    }
  ];

  readonly drinksOptions: SelectItem<{ id: string; alcohol: number }>[] = [
    {
      type: 'group',
      label: 'Beer',
      options: [
        { type: 'option', value: { id: 'Beer 1', alcohol: 0.05 }, label: 'Beer 1' },
        { type: 'option', value: { id: 'Beer 2', alcohol: 0.07 }, label: 'Beer 2' }
      ]
    },
    {
      type: 'group',
      label: 'Wine',
      options: [
        { type: 'option', value: { id: 'Red wine', alcohol: 0.11 }, label: 'Red wine' },
        { type: 'option', value: { id: 'White wine', alcohol: 0.1 }, label: 'White wine' }
      ]
    }
  ];

  // The si-select will always use the provided options. So we only need the id, as it used in drinksEqualCheckFn
  drinkValue = { id: 'Beer 2' };

  actionsOptions: SelectItem<string>[] = [
    { type: 'option', value: 'value-1', label: 'Value 1' },
    { type: 'option', value: 'value-2', label: 'Value 2' },
    { type: 'option', value: 'value-3', label: 'Value 3' },
    { type: 'option', value: 'value-4', label: 'Value 4' },
    { type: 'option', value: 'value-5', label: 'Value 5' },
    { type: 'option', value: 'value-6', label: 'Value 6' },
    { type: 'option', value: 'value-7', label: 'Value 7' },
    { type: 'option', value: 'value-8', label: 'Value 8' },
    { type: 'option', value: 'value-9', label: 'Value 9' },
    { type: 'option', value: 'value-10', label: 'Value 10' },
    { type: 'option', value: 'value-11', label: 'Value 11' }
  ];

  readonly actionsFormControl = new FormControl(['value-1', 'value-3']);
  readonly disableClearButton = signal(false);

  constructor() {
    this.actionsFormControl.valueChanges.subscribe(value =>
      this.disableClearButton.set(!value || value.length === 0)
    );
  }

  selectionChanged(value: string): void {
    const option = this.optionsList.find(o => o.type === 'option' && o.value === value);
    this.logEvent(`Selection: ${this.value}, '${option?.label}'`);
  }

  drinksEqualCheckFn = (drink1: { id: string }, drink2: { id: string }): boolean =>
    drink1.id === drink2.id;

  disableChange(): void {
    if (this.disabled) {
      this.actionsFormControl.disable();
      this.formControl.disable();
    } else {
      this.actionsFormControl.enable();
      this.formControl.enable();
    }
  }

  containActionOption(searchText: string): boolean {
    return this.actionsOptions.some(option => option.label === searchText);
  }

  createOption(optionName: string): void {
    this.actionsOptions = [
      ...this.actionsOptions,
      { value: optionName, label: optionName, type: 'option' }
    ];
  }
}
```

Template:

```html
<div class="p-5 background-1">
  <h4>
    <span id="inline">Inline</span>
  </h4>
  <si-select
    labelledby="inline"
    class="btn btn-ghost"
    [options]="optionsList"
    [disabled]="disabled"
    [readonly]="readonly"
    [hasFilter]="withFilter"
    [(value)]="value"
    (valueChange)="selectionChanged($event)"
  />

  <h4 class="mt-5">
    <span id="form-control">FormControl</span>
  </h4>
  <si-select
    labelledby="form-control"
    class="form-control"
    [options]="optionsList"
    [readonly]="readonly"
    [hasFilter]="withFilter"
    [formControl]="formControl"
    (valueChange)="selectionChanged($event)"
  />

  <h4 class="mt-5">
    <span id="multi-select">Multi select</span>
  </h4>
  <si-select
    labelledby="multi-select"
    multi
    class="form-control"
    placeholder="Select an option"
    [options]="optionsList"
    [disabled]="disabled"
    [readonly]="readonly"
    [hasFilter]="withFilter"
    [(value)]="multiValue"
    (valueChange)="logEvent($event)"
  />

  <h4 class="mt-5">
    <span id="multi-select-with-groups">Multi-select with groups</span>
  </h4>
  <si-select
    labelledby="multi-select-with-groups"
    multi
    class="form-control"
    placeholder="Select on option"
    [options]="groupedOptions"
    [disabled]="disabled"
    [readonly]="readonly"
    [hasFilter]="withFilter"
    [(value)]="groupedMultiValue"
    (valueChange)="logEvent($event)"
  />

  <h4 class="mt-5">
    <span id="custom-template">Select with custom template</span>
  </h4>
  <si-select
    labelledby="custom-template"
    class="form-control"
    [options]="drinksOptions"
    [disabled]="disabled"
    [readonly]="readonly"
    [hasFilter]="withFilter"
    [optionEqualCheckFn]="drinksEqualCheckFn"
    [(value)]="drinkValue"
    (valueChange)="logEvent($event)"
  >
    <ng-template let-option siSelectOptionTemplate>
      <div class="d-flex flex-column">
        <span>{{ option.label! | translate }}</span>
        <span class="si-body-sm text-secondary">Alc.: {{ option.value.alcohol | percent }}</span>
      </div>
    </ng-template>
    <ng-template let-option siSelectValueTemplate>
      {{ option.label! | translate }} (Alc.:{{ option.value.alcohol | percent }})
    </ng-template>
    <ng-template let-group siSelectGroupTemplate>{{
      group.label! | translate | titlecase
    }}</ng-template>
  </si-select>

  <h4 class="mt-5">
    <span id="actions">Select with actions</span>
  </h4>
  <si-select
    labelledby="actions"
    multi
    class="form-control"
    placeholder="Select an option"
    [formControl]="actionsFormControl"
    [hasFilter]="withFilter"
    [options]="actionsOptions"
    [readonly]="readonly"
    (valueChange)="logEvent($event)"
  >
    <ng-template let-searchText="searchText" siSelectActions>
      <button
        siSelectAction
        type="button"
        class="btn btn-link"
        [disabled]="disableClearButton()"
        (click)="actionsFormControl.setValue([])"
        >Clear selection</button
      >
      @if (searchText && !containActionOption(searchText)) {
        <button siSelectAction type="button" class="btn btn-link" (click)="createOption(searchText)"
          >Create "{{ searchText }}" item</button
        >
      }
      <button
        siSelectAction
        type="button"
        class="btn btn-link"
        [selectActionAutoClose]="true"
        (click)="logEvent('Close action')"
        >Close</button
      >
    </ng-template>
  </si-select>
</div>

<div class="card mt-6 e2e-ignore">
  <div class="card-header">Control panel</div>
  <div class="card-body">
    <div class="mb-6"> Current value: {{ value }} </div>
    <div class="mb-6">
      <div class="form-check form-check-inline">
        <label>
          <input type="checkbox" class="form-check-input" [(ngModel)]="readonly" />
          <span class="form-check-label">Readonly</span>
        </label>
      </div>
      <div class="form-check form-check-inline">
        <label>
          <input
            type="checkbox"
            class="form-check-input"
            [(ngModel)]="disabled"
            (ngModelChange)="disableChange()"
          />
          <span class="form-check-label">Disabled</span>
        </label>
      </div>
      <div class="form-check form-check-inline">
        <label>
          <input type="checkbox" class="form-check-input" [(ngModel)]="withFilter" />
          <span class="form-check-label">With filter</span>
        </label>
      </div>
    </div>
  </div>
</div>
```

### Custom select (experimental)

When the rigid `si-select` options API is not enough — for example to embed a tree, drive multi-stage selection with `Apply` / `Cancel` semantics, or render arbitrary UI inside the dropdown — applications can compose their own select from the following primitives:

- `SiCustomSelectDirective` — host directive providing the combobox wiring: `ControlValueAccessor` (`formControl`, `ngModel`, `[(value)]`), disabled / readonly handling, `SiFormItemControl` integration, ARIA `combobox` role, keyboard activation (Enter, Space, ArrowDown / ArrowUp), CDK overlay lifecycle, and focus trapping inside the dropdown.
- `SiSelectComboboxComponent` — the visual trigger that renders the projected value and the dropdown caret. Pair it with `SiSelectComboboxValueComponent` to mark individual selected entries.
- `SiSelectDropdownDirective` — structural directive (`*si-select-dropdown` / `<ng-template si-select-dropdown>`) that registers the dropdown content template with the parent custom select. Requires a `contentType` input whose value is forwarded to the `aria-haspopup` attribute of the combobox host (`menu`, `listbox`, `tree`, `grid`, `dialog`, `true`, or `false`).

The strategy is intentionally minimal: the host directive owns state, focus, keyboard handling and form integration, while applications retain full control over what is rendered in the trigger and in the dropdown. The same component can therefore be styled either as a `form-control` (inside an `si-form-item`, with validation) or as a button (`btn btn-ghost`) by applying the corresponding class on the host element.

A custom select component typically applies `SiCustomSelectDirective` as a host directive and exposes the inputs and outputs the application needs:

```
@Component({
  selector: 'app-tree-select',
  imports: [SiSelectComboboxComponent, SiSelectDropdownDirective, SiTreeViewComponent],
  template: `
    <si-select-combobox>
      @if (select.value(); as val) {
        {{ val }}
      } @else {
        <span class="text-secondary">Select a location...</span>
      }
    </si-select-combobox>

    <ng-template si-select-dropdown contentType="tree">
      <si-tree-view
        ariaLabel="Locations"
        [items]="items()"
        [enableSelection]="true"
        [singleSelectMode]="true"
        (treeItemClicked)="selectItem($event)"
      />
    </ng-template>
  `,
  hostDirectives: [
    {
      directive: SiCustomSelectDirective,
      inputs: ['disabled', 'readonly', 'value'],
      outputs: ['valueChange']
    }
  ]
})
export class TreeSelectComponent {
  protected readonly select = inject<SiCustomSelectDirective<string>>(SiCustomSelectDirective);

  readonly items = input<TreeItem[]>([]);

  selectItem(item: TreeItem): void {
    if (item.label) {
      this.select.updateValue(item.label as string);
      this.select.close();
    }
  }
}
```

Because `si-tree-view` (and similar components) mutate the model they render, inputs must be deep-cloned before they are passed in. A robust pattern is to keep a `pendingItems` signal that is repopulated from a fresh `JSON.parse(JSON.stringify(...))` clone whenever the dropdown opens, so each opening starts from a clean slate without leaking state back to the caller.

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { Component, inject, input, signal } from '@angular/core';
import { FormControl, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import { SiCardComponent } from '@siemens/element-ng/card';
import { SiFormItemComponent } from '@siemens/element-ng/form';
import {
  SiCustomSelectDirective,
  SiSelectComboboxComponent,
  SiSelectComboboxValueComponent,
  SiSelectDropdownDirective
} from '@siemens/element-ng/select';
import { SiTreeViewComponent, TreeItem } from '@siemens/element-ng/tree-view';

import { treeItems } from '../si-tree-view/tree-items';

/**
 * Reusable tree-select built with SiCustomSelectDirective as a host directive.
 * Embeds an si-tree-view inside the dropdown and lets the user pick a location.
 */
@Component({
  selector: 'app-tree-select',
  imports: [
    SiSelectComboboxComponent,
    SiSelectComboboxValueComponent,
    SiSelectDropdownDirective,
    SiTreeViewComponent
  ],
  template: `
    <si-select-combobox>
      @if (select.value(); as val) {
        <si-select-combobox-value [icon]="val.icon">
          {{ val.label }}
        </si-select-combobox-value>
      } @else {
        <span class="text-secondary">Select a location...</span>
      }
    </si-select-combobox>

    <ng-template si-select-dropdown contentType="tree">
      <si-tree-view
        class="d-block mt-n4 dropdown-menu-scroller"
        ariaLabel="Locations"
        [items]="pendingItems()"
        [enableSelection]="true"
        [singleSelectMode]="true"
        [isVirtualized]="false"
        (treeItemClicked)="selectItem($event)"
      />
      <div class="dropdown-divider"></div>
      <div class="d-flex flex-column align-items-start">
        <button
          type="button"
          class="btn btn-link mx-5 my-4"
          [disabled]="!select.value()"
          (click)="clearSelection()"
          >Clear selection</button
        >
      </div>
    </ng-template>
  `,
  hostDirectives: [
    {
      directive: SiCustomSelectDirective,
      inputs: ['disabled', 'readonly', 'value'],
      outputs: ['valueChange']
    }
  ]
})
export class TreeSelectComponent {
  protected readonly select = inject<SiCustomSelectDirective<TreeItem>>(SiCustomSelectDirective);

  /** The tree items to display. */
  readonly items = input<TreeItem[]>([]);

  /**
   * Pending tree items rendered inside the dropdown. The tree view mutates the
   * model (e.g. selection state), so we deep-clone the input before each open
   * to avoid leaking state back into the caller's data.
   */
  protected readonly pendingItems = signal<TreeItem[]>([]);

  constructor() {
    this.select.openChange.subscribe(open => {
      if (open) {
        const clone = JSON.parse(JSON.stringify(this.items())) as TreeItem[];
        applySelectionState(clone, this.select.value()?.label as string | undefined);
        this.pendingItems.set(clone);
      } else {
        this.pendingItems.set([]);
      }
    });
  }

  selectItem(item: TreeItem): void {
    if (item.label) {
      this.select.updateValue(item);
      this.select.close();
    }
  }

  clearSelection(): void {
    this.select.updateValue(undefined);
    this.select.close();
  }
}

/** Marks the item matching `selected` as selected. */
const applySelectionState = (items: TreeItem[], selected: string | undefined): void => {
  for (const item of items) {
    if (item.children?.length) {
      applySelectionState(item.children, selected);
    } else {
      item.selected = item.label === selected;
    }
  }
};

@Component({
  selector: 'app-sample',
  imports: [
    TreeSelectComponent,
    FormsModule,
    ReactiveFormsModule,
    SiCardComponent,
    SiFormItemComponent
  ],
  templateUrl: './si-select-custom.html',
  host: { class: 'p-5' }
})
export class SampleComponent {
  selectedLocation: TreeItem | undefined;
  disabled = false;
  readonly = false;
  readonly treeItems = treeItems;
  readonly locationControl = new FormControl<TreeItem | undefined>(undefined, Validators.required);

  toggleDisabled(disabled: boolean): void {
    if (disabled) {
      this.locationControl.disable();
    } else {
      this.locationControl.enable();
    }
  }
}
```

Template:

```html
<si-card class="card-outline" heading="Button variant">
  <div class="card-body" body>
    <app-tree-select
      class="btn btn-ghost fw-normal"
      [items]="treeItems"
      [disabled]="disabled"
      [readonly]="readonly"
      [(ngModel)]="selectedLocation"
    />
  </div>
</si-card>

<si-card class="mt-6" heading="Form-control variant">
  <div class="card-body" body>
    <si-form-item label="Location (required)">
      <app-tree-select
        class="form-control"
        [items]="treeItems"
        [readonly]="readonly"
        [formControl]="locationControl"
      />
    </si-form-item>
  </div>
</si-card>

<div class="card mt-6 e2e-ignore">
  <div class="card-header">Control panel</div>
  <div class="card-body">
    <div class="mb-6">Current value (ngModel): {{ selectedLocation?.label ?? 'none' }}</div>
    <div class="mb-6"
      >Current value (formControl): {{ locationControl.value?.label ?? 'none' }}</div
    >
    <div class="mb-6">Location valid: {{ locationControl.valid }}</div>
    <div class="mb-5">
      <si-form-item class="form-switch" label="Readonly">
        <input type="checkbox" class="form-check-input" [(ngModel)]="readonly" />
      </si-form-item>
    </div>
    <div class="mb-5">
      <si-form-item class="form-switch" label="Disabled">
        <input
          type="checkbox"
          class="form-check-input"
          [(ngModel)]="disabled"
          (ngModelChange)="toggleDisabled($event)"
        />
      </si-form-item>
    </div>
  </div>
</div>
```

The same primitives can drive a multi-select with `Apply` / `Cancel`. The host component buffers pending changes while the dropdown is open and only calls `select.updateValue(...)` once the user confirms — keeping the `ControlValueAccessor` value stable until the selection is applied.

#### Example

Component:

```typescript
/**
 * Copyright (c) Siemens 2016 - 2026
 * SPDX-License-Identifier: MIT
 */
import { Component, inject, input, signal } from '@angular/core';
import { FormControl, FormsModule, ReactiveFormsModule, Validators } from '@angular/forms';
import {
  SiAutoCollapsableListDirective,
  SiAutoCollapsableListItemDirective,
  SiAutoCollapsableListOverflowItemDirective
} from '@siemens/element-ng/auto-collapsable-list';
import { SiCardComponent } from '@siemens/element-ng/card';
import { SiFormItemComponent } from '@siemens/element-ng/form';
import {
  SiCustomSelectDirective,
  SiSelectComboboxComponent,
  SiSelectComboboxValueComponent,
  SiSelectDropdownDirective
} from '@siemens/element-ng/select';
import { SiTreeViewComponent, TreeItem } from '@siemens/element-ng/tree-view';

import { treeItems } from '../si-tree-view/tree-items';
import {
  cloneTreeWithCheckedState,
  collectCheckedLeaves,
  compactSelected,
  expandCompactItems
} from './tree-select-utils';

/**
 * Reusable multi-select tree component with an Apply button.
 * Uses SiCustomSelectDirective as a host directive and checkboxes in the tree view.
 *
 * When all children of a parent are selected only the parent label is shown
 * in the value display instead of every individual leaf.
 */
@Component({
  selector: 'app-tree-multi-select',
  imports: [
    SiAutoCollapsableListDirective,
    SiAutoCollapsableListItemDirective,
    SiAutoCollapsableListOverflowItemDirective,
    SiSelectComboboxComponent,
    SiSelectComboboxValueComponent,
    SiSelectDropdownDirective,
    SiTreeViewComponent
  ],
  template: `
    <si-select-combobox class="text-nowrap">
      <div class="d-flex flex-fill overflow-hidden" siAutoCollapsableList>
        @if (select.value(); as value) {
          @for (item of value; track item.label) {
            <si-select-combobox-value
              class="comma-separated"
              siAutoCollapsableListItem
              [icon]="item.icon"
            >
              {{ item.label }}
            </si-select-combobox-value>
          } @empty {
            <span class="text-secondary">Select locations...</span>
          }
        } @else {
          <span class="text-secondary">Select locations...</span>
        }
        <span
          #overflow="siAutoCollapsableListOverflowItem"
          siAutoCollapsableListOverflowItem
          class="pill py-0 ms-2"
          >{{ overflow.hiddenItemCount }}+</span
        >
      </div>
    </si-select-combobox>

    <ng-template si-select-dropdown contentType="dialog">
      <div role="dialog" aria-label="Select locations">
        <si-tree-view
          class="d-block mt-n4 dropdown-menu-scroller"
          ariaLabel="Locations"
          [items]="pendingItems()"
          [enableCheckbox]="true"
          [inheritChecked]="true"
          [isVirtualized]="false"
        />
        <div class="d-flex gap-5 justify-content-end p-5 pb-2 border-top">
          <button type="button" class="btn btn-secondary" (click)="cancel()">Cancel</button>
          <button type="button" class="btn btn-primary" (click)="apply()">Apply</button>
        </div>
      </div>
    </ng-template>
  `,
  hostDirectives: [
    {
      directive: SiCustomSelectDirective,
      inputs: ['disabled', 'readonly', 'value'],
      outputs: ['valueChange']
    }
  ]
})
export class TreeMultiSelectComponent {
  protected readonly select = inject<SiCustomSelectDirective<TreeItem[]>>(SiCustomSelectDirective);

  /** The tree items to display. */
  readonly items = input.required<TreeItem[]>();

  /** Pending tree items with checkbox state (not yet applied). */
  protected readonly pendingItems = signal<TreeItem[]>([]);

  constructor() {
    this.select.openChange.subscribe(open => {
      if (open) {
        // Expand any compacted parent-items back to leaf labels so the
        // tree checkbox state is restored correctly.
        const compacted = this.select.value() ?? [];
        const expanded = expandCompactItems(compacted);
        this.pendingItems.set(cloneTreeWithCheckedState(this.items(), expanded));
      } else {
        this.pendingItems.set([]);
      }
    });
  }

  apply(): void {
    const checkedLeaves = collectCheckedLeaves(this.pendingItems());
    // Compact items so fully-selected subtrees are replaced by the parent
    // item (e.g. 'Milano' instead of every individual location).
    const compacted = compactSelected(this.items(), checkedLeaves);
    this.select.updateValue(compacted);
    this.select.close();
  }

  cancel(): void {
    this.select.close();
  }
}

@Component({
  selector: 'app-sample',
  imports: [
    TreeMultiSelectComponent,
    FormsModule,
    ReactiveFormsModule,
    SiCardComponent,
    SiFormItemComponent
  ],
  templateUrl: './si-select-multi-custom.html',
  host: { class: 'p-5' }
})
export class SampleComponent {
  selectedLocations: TreeItem[] = [];
  disabled = false;
  readonly = false;
  readonly treeItems = treeItems;
  readonly locationsControl = new FormControl<TreeItem[]>([], {
    nonNullable: true,
    validators: Validators.required
  });

  toggleDisabled(disabled: boolean): void {
    if (disabled) {
      this.locationsControl.disable();
    } else {
      this.locationsControl.enable();
    }
  }

  labelsOf(items: TreeItem[]): string[] {
    return items.map(item => item.label as string);
  }
}
```

Template:

```html
<si-card class="card-outline" heading="Button variant">
  <div class="card-body" body>
    <app-tree-multi-select
      class="btn btn-ghost fw-normal w-100"
      [items]="treeItems"
      [disabled]="disabled"
      [readonly]="readonly"
      [(ngModel)]="selectedLocations"
    />
  </div>
</si-card>

<si-card class="mt-6" heading="Form-control variant">
  <div class="card-body" body>
    <si-form-item label="Locations (required)">
      <app-tree-multi-select
        class="form-control"
        [items]="treeItems"
        [readonly]="readonly"
        [formControl]="locationsControl"
      />
    </si-form-item>
  </div>
</si-card>

<div class="card mt-6 e2e-ignore">
  <div class="card-header">Control panel</div>
  <div class="card-body">
    <div class="mb-6"
      >Selected (ngModel):
      {{ selectedLocations.length ? labelsOf(selectedLocations).join(', ') : 'none' }}</div
    >
    <div class="mb-6"
      >Selected (formControl):
      {{
        locationsControl.value.length ? labelsOf(locationsControl.value).join(', ') : 'none'
      }}</div
    >
    <div class="mb-6">Locations valid: {{ locationsControl.valid }}</div>
    <div class="mb-5">
      <si-form-item class="form-switch" label="Readonly">
        <input type="checkbox" class="form-check-input" [(ngModel)]="readonly" />
      </si-form-item>
    </div>
    <div class="mb-5">
      <si-form-item class="form-switch" label="Disabled">
        <input
          type="checkbox"
          class="form-check-input"
          [(ngModel)]="disabled"
          (ngModelChange)="toggleDisabled($event)"
        />
      </si-form-item>
    </div>
  </div>
</div>
```

### [SiSelectComponent](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.component.ts#L56-L145>)

**Kind:** component

**Selector:** `si-select`

```
import { SiSelectComponent } from '@siemens/element-ng/select';
```

```
component SiSelectComponent<T> implements SiFormItemControl
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [ariaLabel](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.component.ts#L81-L81>) | `string \| null` | `null` | Aria label of the select. |
| [disabled](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L123-L123>) | `boolean` | `false` | Whether the select input is disabled. |
| [errormessageId](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L195-L195>) | `string` | `` `${this.id()}-errormessage` `` | This ID will be bound to the `aria-describedby` attribute of the select.<br><br>Implements [SiFormItemControl](<index.html#t:SiFormItemControl>) |
| [filterPlaceholder](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.component.ts#L93-L93>) | `TranslatableString` | `` $localize`:@@SI_SELECT.SEARCH-PLACEHOLDER:Search…` `` | Placeholder for search input field. |
| [hasFilter](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.component.ts#L134-L134>) | `boolean` | `false` | Enables the filter input |
| [id](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L115-L115>) | `string` | `` `__si-select-${SiCustomSelectDirective.idCounter++}` `` | Unique identifier.<br><br>Implements [SiFormItemControl](<index.html#t:SiFormItemControl>) |
| [labelledby](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L138-L138>) | `string \| undefined` | `undefined` | Aria labelledby of the select. |
| [noResultsFoundLabel](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.component.ts#L102-L104>) | `TranslatableString` | `` $localize`:@@SI_SELECT.NO-RESULTS-FOUND:No results found` `` | Label if no item can be found. |
| [placeholder](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.component.ts#L106-L106>) | `TranslatableString \| undefined` |  | Placeholder text to display when no options are selected. |
| [readonly](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L130-L130>) | `boolean` | `false` | Readonly state. Similar to disabled but with higher contrast. |
| [scrollStrategy](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L145-L147>) | `ScrollStrategy` | `defaultConnectedOverlayScrollStrategy()` | Optional CDK scroll strategy used for the custom select overlay. |

#### Output Properties

| Name | Type | Description |
| --- | --- | --- |
| [openChange](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L150-L150>) | `boolean` | Emits when the dropdown open state changes. |

#### Attributes and Methods

##### close

[Source for close](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.component.ts#L142-L144>)

Closes the `si-select`.

```
close(): void
```

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

##### labelledbyInput

[Source for labelledbyInput](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.component.ts#L84-L84>)

**Modifiers:** readonly

**Type:** `InputSignal<string | undefined>`

**Default:** `this.select.labelledbyInput`

Aria labelledby of the select.

##### open

[Source for open](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.component.ts#L137-L139>)

Opens the `si-select`.

```
open(): void
```

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

### [Simple options (via SiSelectSimpleOptionsDirective)](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-simple-options.directive.ts#L25-L43>)

**Kind:** directive

**Selector:** `si-select[options]`

```
import { SiSelectSimpleOptionsDirective } from '@siemens/element-ng/select';
```

This directive allows passing [SelectItem](<index.html#t:SelectItem>) to the [SiSelectComponent](<index.html#SiSelectComponent>).

Example:

```html
<si-select [options]="[{ type: 'option', value: 'one', label: 'One' }, { type: 'option', value: 'two', label: 'Two' }]"></si-select>
<si-select [options]="[{ type: 'group', label: 'Group', options [{ type: 'option', value: 1, label: 'One' }, { type: 'option', value: 2, label: 'Two' }] }]"></si-select>
```

```
directive SiSelectSimpleOptionsDirective<T = string> extends SiSelectOptionsStrategyBase<T>
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [optionEqualCheckFn](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-simple-options.directive.ts#L37-L40>) | `(a: T, b: T) => boolean` | `(a: T, b: T): boolean => a === b` | By default, values are check on referential equality. Provide a function to customize the behavior.<br><br>Inherited from `SiSelectOptionsStrategyBase<T>` |
| [options](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-simple-options.directive.ts#L27-L27>) | `SelectItem<T>[] \| null \| undefined` |  | Options to be shown in select dropdown |

#### Attributes and Methods

##### allRows

[Source for allRows](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-simple-options.directive.ts#L42-L42>)

**Modifiers:** readonly

**Type:** `Signal<SelectItem<T>[]>`

**Default:** `computed(() => this.options() ?? [])`

All group and option items in the dropdown.

Inherited from `SiSelectOptionsStrategyBase<T>`

##### onFilter

[Source for onFilter](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-options-strategy.base.ts#L76-L78>)

**Modifiers:** inherited

This function is called when a user enters a filter query. It is expected that an implementation will update the `rows` based on the query.

Inherited from `SiSelectOptionsStrategyBase<T>`

Implements SiSelectOptionsStrategy\<T\>

```
onFilter(filterValue?: string): void
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [filterValue](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-options-strategy.base.ts#L76-L76>) (optional) | `string` |  | • Unprocessed input by user in the filterInput field |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

##### onValueChange

[Source for onValueChange](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-options-strategy.base.ts#L72-L74>)

**Modifiers:** inherited

Is always called when the value changes. The implementation must update [selectedRows](<index.html#SiSelectSimpleOptionsDirective.selectedRows>) when called.

Inherited from `SiSelectOptionsStrategyBase<T>`

Implements SiSelectOptionsStrategy\<T\>

```
onValueChange(value: T[]): void
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [value](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-options-strategy.base.ts#L72-L72>) | `T[]` |  | • currently selected value of the related si-select. |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

##### rows

[Source for rows](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-options-strategy.base.ts#L35-L62>)

**Modifiers:** readonly, inherited

**Type:** `Signal<SelectItem<T>[]>`

**Default:** `[]`

Rows that should be shown.

Inherited from `SiSelectOptionsStrategyBase<T>`

Implements SiSelectOptionsStrategy\<T\>

##### selectedRows

[Source for selectedRows](<https://github.com/siemens/element/blob/main/projects/element-ng/select/options/si-select-options-strategy.base.ts#L64-L70>)

**Modifiers:** readonly, inherited

**Type:** `Signal<SelectOption<T>[]>`

**Default:** `...`

List of all options that are currently selected. Must be updated when [onValueChange](<index.html#SiSelectSimpleOptionsDirective.onValueChange>) is called.

Inherited from `SiSelectOptionsStrategyBase<T>`

Implements SiSelectOptionsStrategy\<T\>

### [SiCustomSelectDirective](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L104-L362>)

**Kind:** directive

**Selector:** `[siCustomSelect]`

```
import { SiCustomSelectDirective } from '@siemens/element-ng/select';
```

Host directive for building custom selects.

Add this as a `hostDirective` on your component and expose the inputs/outputs you need. The directive handles:

• [ControlValueAccessor](<https://angular.dev/api/forms/ControlValueAccessor>) integration (`formControl`, `ngModel`, `[(value)]`)

• Disabled / readonly state management

• Overlay lifecycle for the dropdown (open/close)

• Focus management and focus trapping in the dropdown

• Opening the dropdown on click, Enter, Space, ArrowDown, ArrowUp

• [SiFormItemControl](<index.html#t:SiFormItemControl>) integration

Use [SiSelectDropdownDirective](<index.html#SiSelectDropdownDirective>) to mark the dropdown template in your component, and call [open](<index.html#SiCustomSelectDirective.open>), [close](<index.html#SiCustomSelectDirective.close>), [updateValue](<index.html#SiCustomSelectDirective.updateValue>) from your component logic.

Example:

```ts
@Component({
  selector: 'app-my-select',
  hostDirectives: [{
    directive: SiCustomSelectDirective,
    inputs: ['disabled', 'readonly', 'value'],
    outputs: ['valueChange']
  }],
  template: `
    <si-select-combobox>
      {{ select.value() }}
    </si-select-combobox>
    <ng-template si-select-dropdown contentType="listbox">
      <button (click)="select.updateValue('new'); select.close()">Pick</button>
    </ng-template>
  `
})
export class MySelectComponent {
  readonly select = inject(SiCustomSelectDirective);
}
```

```
directive SiCustomSelectDirective<T> implements ControlValueAccessor, SiFormItemControl
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [disabled](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L123-L123>) | `boolean` | `false` | Whether the select input is disabled. |
| [errormessageId](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L195-L195>) | `string` | `` `${this.id()}-errormessage` `` | This ID will be bound to the `aria-describedby` attribute of the select.<br><br>Implements [SiFormItemControl](<index.html#t:SiFormItemControl>) |
| [id](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L115-L115>) | `string` | `` `__si-select-${SiCustomSelectDirective.idCounter++}` `` | Unique identifier.<br><br>Implements [SiFormItemControl](<index.html#t:SiFormItemControl>) |
| [labelledby](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L138-L138>) | `string \| undefined` | `undefined` | Aria labelledby of the select. |
| [readonly](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L130-L130>) | `boolean` | `false` | Readonly state. Similar to disabled but with higher contrast. |
| [siCustomSelectScrollStrategy](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L145-L147>) | `ScrollStrategy` | `defaultConnectedOverlayScrollStrategy()` | Optional CDK scroll strategy used for the custom select overlay. |
| [value](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L157-L157>) | `T \| null \| undefined` | `undefined` | The current value, supports two-way binding via `[(value)]`. |

#### Output Properties

| Name | Type | Description |
| --- | --- | --- |
| [openChange](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L150-L150>) | `boolean` | Emits when the dropdown open state changes. |
| [valueChange](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L157-L157>) | `T \| null \| undefined` | The current value, supports two-way binding via `[(value)]`. |

#### Attributes and Methods

##### close

[Source for close](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L308-L310>)

Closes the dropdown overlay and restores focus.

```
close(): void
```

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

##### disabled

[Source for disabled](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L198-L198>)

**Modifiers:** readonly

**Type:** `Signal<boolean>`

**Default:** `computed(() => this.disabledInput() || this.disabledByForm())`

Combined disabled state from input and form control.

##### isOpen

[Source for isOpen](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L164-L164>)

**Modifiers:** readonly

**Type:** `WritableSignal<boolean>`

**Default:** `false`

Whether the dropdown is currently open.

##### open

[Source for open](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L253-L305>)

Opens the dropdown overlay.

```
open(event?: Event): void
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [event](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L253-L253>) (optional) | `Event` |  |  |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

##### updateValue

[Source for updateValue](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L246-L250>)

Updates the value programmatically. Call this from your dropdown template to set the new value.

```
updateValue(value: T | null | undefined): void
```

#### Parameters

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [value](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-custom-select.directive.ts#L246-L246>) | `T \| null \| undefined` |  |  |

**Returns:** [void](<https://www.typescriptlang.org/docs/handbook/2/functions.html#void>)

### [SiSelectComboboxComponent](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select-combobox.component.ts#L43-L46>)

**Kind:** component

**Selector:** `si-select-combobox`

```
import { SiSelectComboboxComponent } from '@siemens/element-ng/select';
```

Visual trigger element for custom selects built with [SiCustomSelectDirective](<index.html#SiCustomSelectDirective>). Renders the projected content and a dropdown caret icon.

The ARIA role, focus handling, and state attributes live on the host component via [SiCustomSelectDirective](<index.html#SiCustomSelectDirective>) — this component is purely visual.

Example:

```html
<si-select-combobox>
  {{ select.value() }}
</si-select-combobox>
```

```
component SiSelectComboboxComponent
```

### [SiSelectComboboxValueComponent](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select-combobox-value.component.ts#L52-L64>)

**Kind:** component

**Selector:** `si-select-combobox-value`

```
import { SiSelectComboboxValueComponent } from '@siemens/element-ng/select';
```

Represents a single selected value inside an [SiSelectComboboxComponent](<index.html#SiSelectComboboxComponent>).

Project one `<si-select-combobox-value>` per selected entry. Optional `icon`, `iconColor`, `stackedIcon` and `stackedIconColor` inputs mirror the icon API of [SelectOption](<index.html#t:SelectOption>) and render an icon (with optional stacked overlay) before the projected content.

Add the `comma-separated` CSS class to render a comma between adjacent values. Omit it when using chips, custom separators, or a single value.

Example:

```html
<si-select-combobox>
  <si-select-combobox-value
    icon="element-face-happy"
    iconColor="status-success"
  >
    {{ select.value() }}
  </si-select-combobox-value>
</si-select-combobox>
```

```
component SiSelectComboboxValueComponent
```

#### Input Properties

| Name | Type | Description |
| --- | --- | --- |
| [icon](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select-combobox-value.component.ts#L54-L54>) | `string \| undefined` | An optional icon rendered before the projected content. |
| [iconColor](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select-combobox-value.component.ts#L57-L57>) | `string \| undefined` | Optional CSS color class applied to [icon](<index.html#SiSelectComboboxValueComponent.icon>). |
| [stackedIcon](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select-combobox-value.component.ts#L60-L60>) | `string \| undefined` | Optional secondary icon stacked on top of [icon](<index.html#SiSelectComboboxValueComponent.icon>). |
| [stackedIconColor](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select-combobox-value.component.ts#L63-L63>) | `string \| undefined` | Optional CSS color class applied to [stackedIcon](<index.html#SiSelectComboboxValueComponent.stackedIcon>). |

### [SiSelectDropdownDirective](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select-dropdown.directive.ts#L38-L82>)

**Kind:** directive

**Selector:** `[si-select-dropdown]`

```
import { SiSelectDropdownDirective } from '@siemens/element-ng/select';
```

Structural directive marking the dropdown template for custom selects built with [SiCustomSelectDirective](<index.html#SiCustomSelectDirective>).

When placed on an `<ng-template>`, it automatically registers the template with the parent [SiCustomSelectDirective](<index.html#SiCustomSelectDirective>).

Example:

```html
<ng-template si-select-dropdown contentType="listbox">
  <!-- custom dropdown content -->
</ng-template>
```

```
directive SiSelectDropdownDirective
```

#### Input Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| [closeOnTab](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select-dropdown.directive.ts#L53-L53>) | `boolean` | `false` | Whether pressing Tab closes the dropdown.<br><br>Keep this disabled when the dropdown contains controls that users must reach with Tab. |
| [contentType](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select-dropdown.directive.ts#L44-L44>) (required) | `SiSelectDropdownContentType` |  | Describes the kind of content rendered by the dropdown. The value is forwarded to the `aria-haspopup` attribute of the combobox host of the parent [SiCustomSelectDirective](<index.html#SiCustomSelectDirective>). |

### Types Documentation

### [SelectItem](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L54-L54>)

**Kind:** type alias

```
import type { SelectItem } from '@siemens/element-ng/select';
```

Alias for [SelectOption](<index.html#t:SelectOption>) or [SelectGroup](<index.html#t:SelectGroup>)

```
type SelectItem<T> = SelectGroup<T> | SelectOption<T>
```

### [SiSelectDropdownContentType](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select-dropdown.directive.ts#L15-L16>)

**Kind:** type alias

```
import type { SiSelectDropdownContentType } from '@siemens/element-ng/select';
```

Possible values for the `aria-haspopup` attribute exposed by the combobox host of a custom select.

```
type SiSelectDropdownContentType = 'false' | 'true' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog'
```

### [TranslatableString](<https://github.com/siemens/element/blob/main/projects/element-translate-ng/translate-types/global.types.ts#L18-L18>)

**Kind:** type alias

```
import type { TranslatableString } from '@siemens/element-translate-ng/translate-types';
```

Represents a translatable string. This can either be a translation key, e.g. `ACTIONS.EDIT` that will be automatically translated when displayed on the UI or a pre-translated string, e.g. `Edit`. Equivalent to a normal string in usage and functionality.

```
type TranslatableString = string & Translatable
```

### [SelectOption](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L21-L51>)

**Kind:** interface

```
import type { SelectOption } from '@siemens/element-ng/select';
```

A select option

```
interface SelectOption<T>
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [disabled](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L32-L32>) (optional) | `boolean` | Whether this option is disabled. |
| [icon](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L34-L34>) (optional) | `string` | An optional icon. |
| [iconColor](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L36-L36>) (optional) | `string` | The color of an icon. |
| [label](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L45-L45>) (optional) | `TranslatableString` | A label to be shown for this option. Is optional if a custom template is provided or if the value should directly be rendered. |
| [stackedIcon](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L38-L38>) (optional) | `string` | An optional stacked icon. |
| [stackedIconColor](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L40-L40>) (optional) | `string` | The color of a stacked icon. |
| [type](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L23-L23>) | `"option"` | Defines this to be an option. |
| [typeaheadLabel](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L50-L50>) (optional) | `TranslatableString` | Used for typeahead functionality when filtering is disabled. If provided, this will be used, otherwise the innerText of the rendered element. |
| [value](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L30-L30>) | `T` | The value if this option. It will be used for formControls and the value property of this `si-select`. The value will internally be checked on equality by using `===`. So an app should either use `string` or ensure that same values are referentially equal. |

### [SiFormItemControl](<https://github.com/siemens/element/blob/main/projects/element-ng/form/si-form-item.control.ts#L14-L38>)

**Kind:** interface

```
import type { SiFormItemControl } from '@siemens/element-ng/form';
```

Common interface for form item controls. Controls that should be connected to [SiFormItemComponent](<../../../api/siemens/element-ng/components/SiFormItemComponent/index.html#SiFormItemComponent>) must implement this interface and must be provided using the [SI\_FORM\_ITEM\_CONTROL](<../../../api/siemens/element-ng/types/SI_FORM_ITEM_CONTROL/index.html#t:SI_FORM_ITEM_CONTROL>) token.

```
interface SiFormItemControl
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [errormessageId](<https://github.com/siemens/element/blob/main/projects/element-ng/form/si-form-item.control.ts#L34-L34>) (readonly) | `string \| Signal<string>` | Generated ID that the [SiFormItemComponent](<../../../api/siemens/element-ng/components/SiFormItemComponent/index.html#SiFormItemComponent>) will assign to the element containing the error messages. Implementations of [SiFormItemControl](<index.html#t:SiFormItemControl>) must generate this ID and assign it to the `aria-describedby` attribute of their focusable elements. |
| [id](<https://github.com/siemens/element/blob/main/projects/element-ng/form/si-form-item.control.ts#L16-L16>) (optional, readonly) | `string \| Signal<string \| undefined>` | The actual id of the control that should be used in the `for` attribute of a label. |
| [isFormCheck](<https://github.com/siemens/element/blob/main/projects/element-ng/form/si-form-item.control.ts#L37-L37>) (optional, readonly) | `boolean` | If the control is meant to be used a checkbox. This affects the label positioning. |
| [labelledby](<https://github.com/siemens/element/blob/main/projects/element-ng/form/si-form-item.control.ts#L27-L27>) (optional, readonly) | `string \| Signal<string \| undefined> \| null` | ID that should be assigned to the label element inside the [SiFormItemComponent](<../../../api/siemens/element-ng/components/SiFormItemComponent/index.html#SiFormItemComponent>).<br><br>If the target control is not of type input, select or button, it cannot be referenced by a label. Instead, aria-labelledby must be used to create a reference to a label. In such a case, an implementation of [SiFormItemControl](<index.html#t:SiFormItemControl>) must provide the id of the label in [labelledby](<index.html#t:SiFormItemControl.labelledby>). [SiFormItemComponent](<../../../api/siemens/element-ng/components/SiFormItemComponent/index.html#SiFormItemComponent>) will apply the id to the label so that it can be used inside the control to reference it in the aria-labelledby attribute. |

### [SelectGroup](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L8-L18>)

**Kind:** interface

```
import type { SelectGroup } from '@siemens/element-ng/select';
```

A select option group

```
interface SelectGroup<T>
```

#### Properties

| Name | Type | Description |
| --- | --- | --- |
| [key](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L12-L12>) (optional) | `string` | An optional key to identify this group in a custom template. |
| [label](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L14-L14>) (optional) | `TranslatableString` | A label to be shown as header for this group. Is optional if a custom template is provided. |
| [options](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L17-L17>) | `SelectOption<T>[]` | All options that are part of this group. |
| [type](<https://github.com/siemens/element/blob/main/projects/element-ng/select/si-select.types.ts#L10-L10>) | `"group"` | Defines this to be a group. |
