Skip to content
Edit this page

SiCustomSelectDirective documentation

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 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 integration

Use SiSelectDropdownDirective to mark the dropdown template in your component, and call open, close, updateValue from your component logic.

Example:

@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);
}

Input Properties

Name Type Default Description
disabled
boolean false

Whether the select input is disabled.

errormessageId
string `${this.id()}-errormessage`

This ID will be bound to the aria-describedby attribute of the select.

Implements SiFormItemControl

id
string `__si-select-${SiCustomSelectDirective.idCounter++}`

Unique identifier.

Implements SiFormItemControl

labelledby
string | undefined undefined

Aria labelledby of the select.

readonly
boolean false

Readonly state. Similar to disabled but with higher contrast.

siCustomSelectScrollStrategy
ScrollStrategy defaultConnectedOverlayScrollStrategy()

Optional CDK scroll strategy used for the custom select overlay.

value
T | null | undefined undefined

The current value, supports two-way binding via [(value)].

Output Properties

Name Type Description
openChange
boolean

Emits when the dropdown open state changes.

valueChange
T | null | undefined

The current value, supports two-way binding via [(value)].

Attributes and Methods

Name Type Default Description
close()
() => void

Closes the dropdown overlay and restores focus.

(readonly)disabled
Signal<boolean> computed(() => this.disabledInput() || this.disabledByForm())

Combined disabled state from input and form control.

(readonly)isOpen
WritableSignal<boolean> false

Whether the dropdown is currently open.

open()
(event?: Event) => void

Opens the dropdown overlay.

Parameters
updateValue()
(value: T | null | undefined) => void

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

Parameters

Types Documentation

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

Common interface for form item controls. Controls that should be connected to SiFormItemComponent must implement this interface and must be provided using the SI_FORM_ITEM_CONTROL token.

Properties


Except where otherwise noted, content on this site is licensed under MIT License.