Listbox
vig-listbox ng-template[vigSelectOption]
import { Listbox } from '@vigdx/ui/listbox';
import { SelectOptionTemplate } from '@vigdx/ui/select';Basic
options as ListboxOption objects ( SelectOption plus an optional group ) and bind [(value)] to an array; empty is [] . Without multiple it holds at most one value, which follows the arrow keys like a native <select size> ; the value stays an array either way, so a single-choice form field is typed T[] .
Value: [ "lis" ]
Multiple, checkboxes, filter and groups
multiple keeps the values in selection order. checkbox adds a checkbox per option and a select-all row (only with multiple ; a dev-mode warning says so otherwise), filter a search field that matches labels in the active locale. Consecutive options with the same group form a named group.
Cities: [] · Toppings: [ "basil" ]
Long lists
virtualScroll is 'auto' ) only the rows in view are rendered, with one row height; set virtualScroll to true or false to decide yourself. The height follows --vig-listbox-max-height (15rem), the virtual row height --vig-listbox-row-height (2.25em).
0 of 10 000 selected
Custom options and texts
vigSelectOption template renders each option, as in vig-select ; labels overrides the texts the list adds ( filterPlaceholder , filterAriaLabel , emptyLabel , noResultsLabel , selectAllLabel ).
Forms
vig-listbox implements FormValueControl<T[]> for Signal Forms; import VigValueAccessor for formControl , formControlName or ngModel . Signal Forms' required() treats [] as filled, so require a value with minLength(path, 1) or check the length with validate() . Values compare with === and must be unique (a dev-mode warning flags duplicates).
Pick two or more.
Valid: no · Home: []
Listbox or select
A listbox keeps every option on screen, which suits a handful of choices that people compare or a long list they scan with a filter. When space is short, use a select or a multi select: the same options and value in a dropdown. To order a list, or to move items between two lists, use an order list or a pick list, which build on the listbox.
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="listbox"][data-part="label"] { … }: 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="listbox"]
| Part | Element | data-state |
|---|---|---|
label | — | |
control | — | |
filter | filter ). | — |
select-all | checkbox with multiple ; aria-pressed ). | — |
listbox | role="listbox" ; a cdk-virtual-scroll-viewport while virtualized. | — |
group | role="group" of options sharing a group heading. | — |
group-heading | — | |
option | aria-selected , aria-disabled ). | selected |
checkbox | checkbox ). | — |
check | checkbox ). | — |
status | role="status" region under the list. | — |
empty | — | |
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). | — |
Accessibility
- Follows the WAI-ARIA APG listbox pattern: a
role="listbox"named by the label, witharia-multiselectableinmultiplemode, and options reportingaria-selectedandaria-disabled. - Focus stays on the list and points at the active option through
aria-activedescendant, so it keeps working while the list is virtualized; the active option draws an outline that forced-colors mode keeps, and selection shows a check mark or checkbox, never a tint alone. While virtualized, options carryaria-setsizeandaria-posinset, the reference is set only while the active option is rendered, and the group name describes each option. - ArrowUp and ArrowDown move, Home and End jump, PageUp and PageDown move a page, typing jumps to a matching label. In single mode the selection follows; in
multiplemode Space toggles, Shift+arrows toggle the next option, Shift+Space and Shift+click select a range, Ctrl+Shift+Home/End select to the ends and Ctrl/Cmd+A selects every option (again to clear). - The filter is a search field controlling the list; ArrowDown moves on into the list. When nothing matches, a status message says so.
- Hint and error are linked through
aria-describedby; an invalid list setsaria-invalid, a read-only onearia-readonly(it can still be browsed), a disabled one (aria-disabled) stays focusable, so a long list can still be scrolled and read, but nothing can be selected.
API
Listbox
vig-listboxA list of options shown in the page (APG listbox): one or many values, an
optional filter, checkboxes, groups and virtual scrolling for long lists.
Focus stays on the list and the active option is exposed through
aria-activedescendant, so it keeps working while virtualized. The value
is always an array in selection order ([] when empty); single selection
holds at most one value and follows the arrow keys, like a native
<select size>.
<vig-listbox label="Cities" [options]="cities" [(value)]="picked" multiple filter />| Name | Type | Default | Description |
|---|---|---|---|
checkbox | boolean | false | With |
dirty | boolean | false | — |
disabled | boolean | false | — |
disabledReasons | readonly WithOptionalFieldTree<DisabledReason>[] | [] | — |
errorMessages | Record<string, string> | — | — |
errors | readonly ValidationError.WithOptionalFieldTree[] | [] | — |
filter | boolean | false | A search field above the list that narrows the options by label (locale-aware). |
hidden | boolean | false | — |
hideLabel | boolean | false | Visually hides the label; it still names the list for assistive tech. |
hint | string | undefined | undefined | — |
invalid | boolean | false | — |
label | string | — | Visible label naming the list; also with |
labels | Partial<ListboxLabels> | — | Texts (i18n) over the locale defaults. |
multiple | boolean | false | Allows any number of values: Space toggles, Shift extends, Ctrl/Cmd+A
selects all. Without it the value still is an array, of at most one
value; a Signal Forms |
name | string | '' | — |
options | readonly ListboxOption<T>[] | [] | The options; values compare with |
pending | boolean | false | — |
readonly | boolean | false | — |
required | boolean | false | — |
size | FieldSize | 'md' | Text size and option padding. |
touched | boolean | false | — |
value | T[] | [] | The selected values in selection order; at most one without |
virtualScroll | ListboxVirtualScroll | 'auto' | Renders only the options in view; |
| Name | Payload | Description |
|---|---|---|
touch | void | — |
valueChange | T[] | The selected values in selection order; at most one without |
| 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 the filter text as well; 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 | — |