Cascade select
vig-cascade-select
import { CascadeSelect, CascadeSelectOptionTemplate } from '@vigdx/ui/cascade-select';Basic
optionLabel and optionValue are functions (by default the option's label and the option itself); optionChildren and optionDisabled read children and disabled unless you pass your own. Only options without children are chosen, which writes optionValue(option) to [(value)] ; opening the panel shows the path to the value. Hover or click opens a level, and a diagonal move toward it keeps it open.
Value: MUC
Choosing groups, path and option content
selectableGroups lets a region or a country be chosen too: a click on its label or Enter chooses it, its chevron or ArrowRight opens it. display="path" shows the whole path in the trigger, and a vigCascadeSelectOption template (typed by vigCascadeSelectOptionOf ) renders the options.
Value: TR-AE
Lazy levels
optionChildren returns undefined load through loadChildren(option, signal) the first time they open, and stay loaded. The signal aborts when the level closes first; a rejected promise shows a retry row, and an empty array makes the option a leaf (chosen at once when Enter or a click started the load). valueLabel(value) labels a value whose option is not loaded yet. Return null from optionChildren (or a children: null field) for options that never have children.
Value: none
Signal Forms
[formField] : errors, required, disabled and touched state come from the form. Clearing writes null , so type the field as nullable.
Where you work most days.
Reactive Forms
VigValueAccessor next to the field for formControlName , formControl and ngModel .
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="cascade-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="cascade-select"]
| Part | Element | data-state |
|---|---|---|
field | — | |
label | — | |
trigger | role="combobox" button. | open, closed |
value | — | |
placeholder | — | |
indicator | — | |
clear | clearable ). | — |
panel | — | |
header | — | |
back | — | |
heading | — | |
listbox | role="listbox" of the level the panel shows, named by its option (the field at the top; aria-busy while it loads). | — |
level | role="listbox" named by it, in an overlay beside it. | — |
option | role="option" ( aria-selected , aria-disabled ; options with children are described as having options and are aria-busy while they load). | open, closed |
option-label | — | |
check | — | |
group-indicator | — | |
loading | — | |
level-status | — | |
load-error | — | |
retry | — | |
empty | — | |
status | role="status" region announcing the level entered. | — |
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). | — |
| Attribute | Meaning |
|---|---|
data-opening | <dialog> ) while its entrance transition plays; removed once it settles (2s at most). Style the entrance with data-opening: utilities. |
data-closing | data-closing: utilities. |
Accessibility
- The trigger is an APG
role="combobox"labelled by the field label, witharia-haspopup="listbox". Each level is arole="listbox"named by its option ("Türkiye"; the top level by the field). Focus stays on the trigger: itsaria-controlsnames the listbox of the active level andaria-activedescendantthe active option there; both are left out while the element they name is not on the page (a level still attaching or loading). - Options with a level of their own are described as having options ("has options"), and entering a level is announced through a polite status ("Türkiye, 3 options").
- ArrowDown, ArrowUp, Enter or Space open the panel on the value's path. ArrowUp and ArrowDown move within a level, Home and End to its ends, ArrowRight opens the active option's level and moves into it, ArrowLeft goes back (mirrored in right-to-left pages), typing jumps to an option, Enter or Space chooses it, Escape closes the panel and Tab closes it and moves on.
- The value reads with its path, the option first: "Istanbul, Marmara, Türkiye". An option whose children load is
aria-busyand described by the loading text; a failed load becomes a retry option in its level, and reopening the panel tries again. A value under a disabled option still shows, but the panel opens on the nearest enabled option. - On narrow screens the Back button (and ArrowLeft) returns to the previous level; its targets, like the options, are at least 44px tall on touch screens.
- Texts are translated with the locale or per instance through
labels(ariaLabel,clearAriaLabel,backLabel,hasOptionsLabel,levelAnnouncement,loadingLabel,errorLabel,retryLabel,emptyLabel).
API
CascadeSelect
vig-cascade-selectA form field picking one value from nested options, e.g. country → state → city: the panel shows a level per open option, side by side, and choosing an option without children sets the value. On narrow screens the panel shows one level at a time with a Back button.
Options are your own objects: optionLabel, optionValue,
optionChildren and optionDisabled read them (by default their label,
the option itself, children and disabled), and loadChildren fetches
levels on demand. Values compare with ===.
<vig-cascade-select label="City" [options]="countries" [optionValue]="cityCode" [formField]="form.city" />The trigger is a combobox (APG) whose popup is the listbox of the active
level: focus stays on it and the arrow keys move the active option
(aria-activedescendant), Right (Left in RTL) opens a level, Left goes
back, Enter picks, typing jumps to an option. The chosen value is
announced with its path ("Istanbul, Türkiye"). Works with Signal Forms
and, through VigValueAccessor, with Reactive Forms and ngModel.
While it plays its entrance or exit transition, the animating element
carries data-opening or data-closing (stable hooks for styling and
for waiting in tests; see the theming guide).
panel listbox level option option-label check group-indicator loading level-status load-error retry empty header back heading status
cascade-select
open closed
data-opening data-closing
| Name | Type | Default | Description |
|---|---|---|---|
clearable | boolean | false | Shows a button that clears the value while one is set. |
dirty | boolean | false | — |
disabled | boolean | false | — |
disabledReasons | readonly WithOptionalFieldTree<DisabledReason>[] | [] | — |
display | "label" | "path" | 'label' | The trigger shows the chosen option's |
errorMessages | Record<string, string> | — | — |
errors | readonly ValidationError.WithOptionalFieldTree[] | [] | — |
hidden | boolean | false | — |
hideLabel | boolean | false | Visually hides the label, which still names the field; pair it with a placeholder. |
hint | string | undefined | undefined | — |
invalid | boolean | false | — |
label | string | — | — |
labelPosition | LabelPosition | 'float' |
|
labels | Partial<CascadeSelectLabels> | — | Texts (i18n); locale defaults. |
loadChildren | CascadeSelectLoader<T> | undefined | undefined | Fetches the children of options without their own; see |
name | string | '' | — |
optionChildren | CascadeSelectChildren<T> | defaultOptionChildren | Children of an option: an array (empty or |
optionDisabled | (option: T) => boolean | defaultOptionDisabled | Whether an option is disabled: dimmed, skipped by the keys, never opened or chosen. |
optionLabel | (option: T) => string | defaultOptionLabel | Text of an option; its |
options | readonly T[] | [] | The top-level options. |
optionValue | (option: T) => V | identity | What choosing an option writes to |
pending | boolean | false | — |
placeholder | string | undefined | undefined | Shown in the trigger while nothing is chosen. |
readonly | boolean | false | — |
required | boolean | false | — |
selectableGroups | boolean | false | Options with children can be chosen too (Enter or a click on the label); the chevron opens them. |
size | FieldSize | 'md' | — |
touched | boolean | false | — |
value | V | null | null | The value of the chosen option ( |
valueLabel | ((value: V) => string | undefined) | undefined | undefined | Labels a value whose option is not known: not loaded yet (under a lazy
option) or gone from |
| Name | Payload | Description |
|---|---|---|
touch | void | — |
valueChange | V | null | The value of the chosen option ( |
| 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 | Closes the panel without moving focus or marking the field touched; see |
CascadeSelectOptionTemplate
ng-template[vigCascadeSelectOption]Custom content of the options of vig-cascade-select (in the panel; the
trigger keeps the label text, and options keep optionLabel as their
accessible name). Bind the same top-level options to
vigCascadeSelectOptionOf to type let-option; without it the option is
unknown.
<ng-template vigCascadeSelectOption [vigCascadeSelectOptionOf]="places" let-place>
<span aria-hidden="true">{{ place.flag }}</span> {{ place.name }}
</ng-template>| Name | Type | Default | Description |
|---|---|---|---|
vigCascadeSelectOptionOf | readonly T[] | null | undefined | undefined | Type-only: the options the template renders. Not read at runtime. |