Select

A dropdown for picking one value from a list. Use it when there are too many options to show as radios, or when space is tight; add a filter for long lists.

  • vig-select
  • ng-template[vigSelectOption]
Import
import { Select, SelectOptionTemplate } from '@vigdx/ui/select';

Basic

Pass options as SelectOption objects ( value , label , optional icon and disabled ) and bind [(value)] . Values can be strings, numbers or any other primitive and are compared with === ; the value is null while nothing is selected.

Country

Page size

Country: none · Page size: 25

Icons and disabled options

icon names a registered icon shown before the label, in the list and in the field. An option with disabled: true stays visible but cannot be chosen and is skipped by the arrow keys.

Status

Filter and clear

filter adds a search box at the top of the list; clearable adds a button that sets the value back to null . filterPlaceholder , filterAriaLabel , emptyMessage and clearAriaLabel translate the texts per instance.

Country

Ülke

Custom option template

An <ng-template vigSelectOption let-option> inside the select renders each option and the selected value in the field. option is the whole SelectOption ; bind the same list to [vigSelectOptionOf] (like ngForOf ) so its value is typed. Use the template for icon fonts, avatars or colour dots.

Status

Label on top and hidden label

labelPosition="top" puts the label above the field. In dense toolbars such as table filters, hideLabel drops the visible label but keeps it as the accessible name; pair it with a placeholder .

Billing country

Shipping country

Hint, error, states and sizes

hint adds help text; errors show once the field is touched and invalid . disabled blocks the field, readonly keeps it focusable but does not open the list. size is sm , md (default) or lg .

Country

Used for billing and tax.

Country

Choose the country you are billed in.

Disabled

Read-only

Small

Medium

Large

Reactive Forms

Import VigValueAccessor next to the component to use formControlName , [formControl] or ngModel . Type the control with the option value type plus null .

Country

Status

{
  "country": null,
  "status": "active"
}

Signal Forms

vig-select implements FormValueControl<T | null> . Clearing writes null , so type model fields of clearable selects as nullable.

Country

Status

{
  "country": null,
  "status": "active"
}

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="select"][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="select"]

Select styling hooks
Part Element data-state
field Positioned wrapper of the label, trigger and buttons. —
label The visible (or floating) label. —
trigger The role="combobox" button. open, closed
value The selected option in the trigger. —
placeholder The placeholder text in the trigger. —
indicator The chevron. —
clear The clear button ( clearable ). —
panel The overlay panel, rendered in the overlay container. —
listbox The role="listbox" list inside the panel. —
option One option ( aria-selected , aria-disabled ). —
empty The "no results" row. —
filter The search field at the top of the panel ( filter ). —
check The check mark of the selected option. —
hint The vig-hint (a display: contents host; style its text part). —
disabled-reason The vig-hint with the disabled reason ( display: contents ). —
error The vig-field-error (a display: contents host; style its message part). —

Accessibility

  • Follows the APG select-only combobox pattern: the field is a role="combobox" with aria-expanded and aria-controls, the list a role="listbox" of role="option" items with aria-selected.
  • Focus stays on the field; the highlighted option is exposed through aria-activedescendant and drawn with an outline that forced-colors mode keeps. With filter, the trigger opens a labelled role="dialog" (aria-haspopup="dialog") holding the filter box, itself a combobox (aria-autocomplete="list") driving the list. ArrowDown, ArrowUp, Enter and Space open the list; the arrows, Home and End move, Enter or Space select, Escape closes and typing jumps to the first matching label.
  • The field is named by its label (also with hideLabel); ariaLabel overrides the name. The clear button and filter box have their own translatable labels.
  • required, readonly and an invalid state set aria-required, aria-readonly and aria-invalid; hint and error are linked through aria-describedby.
  • Icons and custom template content should be decorative; the option label is what screen readers announce.

API

Select

vig-select component
Select props
Name Type Default Description
ariaLabelstring | undefinedundefined
—
clearablebooleanfalse
—
clearAriaLabelstring | undefinedundefined
—
dirtybooleanfalse
—
disabledbooleanfalse
—
disabledReasonsreadonly WithOptionalFieldTree<DisabledReason>[][]
—
emptyMessagestring | undefinedundefined
—
errorMessagesRecord<string, string>—
—
errorsreadonly ValidationError.WithOptionalFieldTree[][]
—
filterbooleanfalse
—
filterAriaLabelstring | undefinedundefined
—
filterPlaceholderstring | undefinedundefined
—
hiddenbooleanfalse
—
hideLabelbooleanfalse

Visually hides the label — it still names the control for assistive tech — and drops the row reserved for it, giving a shorter control for dense toolbars such as table filters. Pair it with a placeholder.

hintstring | undefinedundefined
—
invalidbooleanfalse
—
label required string—
—
labelPositionLabelPosition'float'

float (default) rests the label inside the field; top sets it above a shorter field, for forms laid out with labels over their controls.

namestring''
—
optionsreadonly SelectOption<T>[][]
—
pendingbooleanfalse
—
placeholderstring | undefinedundefined
—
readonlybooleanfalse
—
requiredbooleanfalse
—
sizeFieldSize'md'
—
touchedbooleanfalse
—
value model T | nullnull
—

SelectOptionTemplate

ng-template[vigSelectOption] directive

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.

Example :
<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>
SelectOptionTemplate props
Name Type Default Description
vigSelectOptionOfreadonly SelectOption<T>[] | null | undefinedundefined

Type-only: the options the template renders, so the template type checker infers the option value type. Not read at runtime.

VigValueAccessor

directive

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.

VigValueAccessor methods
Signature Description
registerOnChange(fn: (value: unknown) => void): void
—
registerOnTouched(fn: () => void): void
—
setDisabledState(disabled: boolean): void
—
writeValue(value: unknown): void
—

Are you sure?