Autocomplete
vig-autocomplete ng-template[vigSelectOption]
import { Autocomplete } from '@vigdx/ui/autocomplete';
import { SelectOptionTemplate } from '@vigdx/ui/select';Basic
options and bind [(value)] ; the list narrows to labels containing the typed text. minQueryLength sets how many characters open the list ( 0 opens it on focus) and clearable adds a clear button. Text that matches no option reverts on blur.
Suggestions open on focus.
Destination: none · Origin: ist
Server search
[localFilter]="false" the field shows options as given. Listen to searchRequest , which fires once typing pauses for debounce ms, load results into options and set loading meanwhile to show a spinner. queryChange is the undebounced counterpart: it emits the text on every keystroke, e.g. for a character counter; use searchRequest for requests.
Results come from a (simulated) server.
Value: none
Object values
displayWith sets the text shown in the field for the selected value.
Assignee: [email protected]
Free text
allowCustom keeps typed text that matches no option as the value, so suggestions are optional. Use it with string values.
Pick a suggestion or keep your own text.
Value: none
Label, error, states and sizes
labelPosition="top" puts the label above the field and emptyMessage replaces the "no results" text. Errors show once the field is touched and invalid . size is sm , md (default) or lg .
Reactive Forms
VigValueAccessor next to the component to use formControlName , [formControl] or ngModel .
Signal Forms
vig-autocomplete implements FormValueControl<T | null> . Its query length input is called minQueryLength so that it does not clash with the minLength rule of Signal Forms.
Valid: no · Office: none
Styling hooks
Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="autocomplete"][data-part="field"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.
Scope: [data-scope="autocomplete"]
| Part | Element | data-state |
|---|---|---|
field | — | |
label | — | |
input | <input> . | — |
hint | vig-hint (a display: contents host; style its text part). | — |
disabled-reason | vig-hint with the disabled reason ( display: contents ). | — |
error | vig-field-error (a display: contents host; style its message part). | — |
spinner | loading . | — |
clear | clearable ). | — |
panel | — | |
listbox | role="listbox" list inside the panel. | — |
option | aria-selected , aria-disabled ). | — |
empty | — | |
loading | — | |
check | — |
Accessibility
- Follows the APG combobox-with-list-autocomplete pattern: the input has
role="combobox",aria-autocomplete="list",aria-expandedandaria-controlspointing at arole="listbox". - Focus stays in the input. ArrowDown and ArrowUp move through the suggestions (exposed with
aria-activedescendant), Enter picks one, Escape closes the list. - While
loadingthe input setsaria-busyand the list shows arole="status"message (loadingLabel), so the wait is announced. - The input is named by a real
<label for>; hint and error are linked througharia-describedby.clearAriaLabel,emptyMessageandloadingLabeltranslate the added texts.
API
Autocomplete
vig-autocompleteText field with a suggestion list (APG combobox with list autocomplete).
Suggestions come from options, filtered locally by label, or from the
server: listen to searchRequest (debounced), set localFilter to false, and
feed the results back through options while loading shows a spinner.
Focus stays in the input; the active option is exposed through
aria-activedescendant. Empty is null.
| Name | Type | Default | Description |
|---|---|---|---|
allowCustom | boolean | false | Keeps typed text that matches no option as the value (string models). |
clearable | boolean | false | — |
clearAriaLabel | string | undefined | undefined | — |
debounce | number | 250 | Delay before |
dirty | boolean | false | — |
disabled | boolean | false | — |
disabledReasons | readonly WithOptionalFieldTree<DisabledReason>[] | [] | — |
displayWith | ((value: T) => string) | undefined | undefined | Text shown in the field for a value; defaults to the option label. |
emptyMessage | string | undefined | undefined | — |
errorMessages | Record<string, string> | — | — |
errors | readonly ValidationError.WithOptionalFieldTree[] | [] | — |
hidden | boolean | false | — |
hideLabel | boolean | false | Visually hides the label; it still names the control for assistive tech. |
hint | string | undefined | undefined | — |
invalid | boolean | false | — |
label | string | — | — |
labelPosition | LabelPosition | 'float' |
|
loading | boolean | false | Shows a spinner while server suggestions are on their way. |
loadingLabel | string | undefined | undefined | — |
localFilter | boolean | true | Narrows |
minQueryLength | number | 1 | Characters needed before suggestions open (0 opens on focus). Not named
|
name | string | '' | — |
options | readonly SelectOption<T>[] | [] | — |
pending | boolean | false | — |
placeholder | string | undefined | undefined | — |
readonly | boolean | false | — |
required | boolean | false | — |
size | FieldSize | 'md' | — |
touched | boolean | false | — |
value | T | null | null | — |
| Name | Payload | Description |
|---|---|---|
queryChange | string | The typed text, on every keystroke. |
searchRequest | string | The typed text once typing pauses for |
touch | void | — |
valueChange | T | null | — |
| Signature | Description |
|---|---|
focus(options?: FocusOptions): void | Moves focus to the control's interactive element (the input, or the
trigger of a popup control). Signal Forms calls it through
|
reset(): void | Drops typed text and closes the suggestions; see |
SelectOptionTemplate
ng-template[vigSelectOption]Custom rendering for options of vig-select, vig-multi-select,
vig-listbox and vig-select-button, replacing the default icon + label. vig-select also
uses it for the selected value shown in the trigger.
Bind the same options to vigSelectOptionOf (like ngForOf) to type
let-option in the template; without it the option value is unknown.
<vig-select label="Status" [options]="statuses">
<ng-template vigSelectOption [vigSelectOptionOf]="statuses" let-option>
<i [class]="option.value" aria-hidden="true"></i> {{ option.label }}
</ng-template>
</vig-select>| Name | Type | Default | Description |
|---|---|---|---|
vigSelectOptionOf | readonly SelectOption<T>[] | null | undefined | undefined | Type-only: the options the template renders, so the template type checker infers the option value type. Not read at runtime. |
VigValueAccessor
Bridges the vigdx form fields to Reactive Forms (formControl,
formControlName) and template-driven forms (ngModel). Import it next to
the component; Signal Forms ([formField]) need no accessor.
| Signature | Description |
|---|---|
registerOnChange(fn: (value: unknown) => void): void | — |
registerOnTouched(fn: () => void): void | — |
setDisabledState(disabled: boolean): void | — |
writeValue(value: unknown): void | — |