SiCustomSelectDirective documentation¶
selector
[siCustomSelect]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: 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. |
| id ¶ | string | __si-custom-select-${SiCustomSelectDirective.idCounter++} | Unique identifier. |
| readonly ¶ | boolean | false | Readonly state. Similar to disabled but with higher contrast. |
| value ¶ | T | 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 | 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> | ... | 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 | undefined)) => void | Updates the value programmatically. Call this from your dropdown template to set the new value. Parameters
|
Types Documentation¶
| 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. | |||||
|---|---|---|---|---|---|
|
Variable |
|---|
| Possible values for the aria-haspopup attribute exposed by the combobox host of a custom select. |
|---|
|
| Interface for form error mapper. It resolves a key to either a translatable string or function which is called with the validation error for its key and should return a translatable string. | |
|---|---|
| |
| 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. |
|---|
Translatable import imported from @siemens/element-translate-ng |
|---|
|
| Structural directive marking the dropdown template for custom selects built with SiCustomSelectDirective . When placed on an <ng-template> , it automatically registers the template with the parent SiCustomSelectDirective .Example: | |||
|---|---|---|---|
| |||
|
| ||||||||||||
| ||||||||||||
|
| |||||||||||
| |||||||||||
| |||||||||||
|
| ||||||||||||
| ||||||||||||
|
Except where otherwise noted, content on this site is licensed under MIT License.