Skip to content

Select ​

hx-select is a listbox in a CDK overlay with a combobox trigger. It needs @angular/cdk (a peer dependency) and the overlay styles that come with styles.css.

html
<label for="city">City</label>
<hx-select inputId="city" placeholder="Select a city" [options]="cities"
           optionLabel="name" optionValue="code" [(ngModel)]="city" showClear />
<hx-select [options]="['Free', 'Pro', 'Team']" [formField]="form.plan" />
InputTypeDefaultDescription
optionsunknown[][]Objects or primitives.
optionLabelstring'label'Property shown for an object option.
optionValuestring'value'Property used as the value; without it the option itself is used.
optionDisabledstring'disabled'Property that disables an option.
placeholderstringShown while nothing is selected.
emptyMessagestring'No options'Shown when there are no options.
filterbooleanfalseA search field above the list (case-insensitive "contains").
filterPlaceholderstring'Search'Placeholder and accessible name of the search field.
filterBystring | (option) => stringthe labelWhat the filter matches: a property name or accessor.
emptyFilterMessagestring'No results'Shown when the filter matches nothing.
variant'outlined' | 'filled''outlined'A tinted field instead of an outline.
size'small' | 'medium' | 'large''medium'Font size and padding.
fluidbooleanfalseFull width of the container.
showClearbooleanfalseA button that resets the value to null.
inputIdstringId of the trigger, for <label for>.
ariaLabelstringAccessible name when there is no visible label.
ariaLabelledbystringId of the element that names the select (aria-labelledby of the trigger).
ariaDescribedbystring | nullId of a text that describes the select (aria-describedby of the trigger).
compareWith(a, b) => booleanObject.isHow a value is matched to an option.
  • Forms: works with ngModel, reactive forms (it is a ControlValueAccessor) and signal forms ([formField], it implements the form value control contract); [(value)] binds it without forms.
  • Keyboard: Arrow Down/Up or Enter opens it; in the list the arrows, Home, End and typeahead move, Enter or Space selects (with filter the field has focus first and Arrow Down moves into the list; the field is cleared when the panel closes), Escape closes and returns focus to the trigger, Tab closes.
  • Accessibility: the trigger is a combobox with aria-expanded and aria-controls, the list a listbox of options. Give it a visible label or ariaLabel.

Tokens ​

The look comes from the design tokens --h-select-* (see Theming); override them in your theme, never the component CSS.

Part of @gravionlabs/helix-ui; all components are listed in the component reference.

Released under the MIT licence.