# SiCustomSelectDirective documentation

**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](<../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>)

### Types Documentation

### [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](<../../components/SiFormItemComponent/index.html#SiFormItemComponent>) must implement this interface and must be provided using the [SI\_FORM\_ITEM\_CONTROL](<../../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](<../../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](<../../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](<../../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. |
