Skip to main content
Neural UIv2.0.0Documentation
View v1 GitHub

Listbox

Keep options visible with keyboard navigation, search and multiple selection.

Category
Forms and selection
Import
@neural-ui/core/listbox
Selector
neu-listbox
import { NeuListboxComponent } from '@neural-ui/core/listbox';

Usage

Choose Listbox when the choices should remain visible rather than opening an overlay. Single and multiple modes use the same value contract as Select.

In multiple mode, checkbox indicators make selection explicit. Toggle-all affects visible enabled options. Virtual scrolling keeps the option viewport bounded for larger collections.

Signal Forms

Bind FormField to the value-owning control and add required to the form schema. Select a destination, leave the field to mark it touched, and reset it to check both value and validation state. A required marker on its own does not validate your form.

Signal Forms guide

Signal Forms
Madrid
Lisbon
Paris
Rome

Value: โ€” ยท Valid: false

Try and configure

Change the settings below and interact with the live control. The preview, current application value and generated template stay together. A disabled destination lets you check that unavailable choices cannot be selected.

Try and configure
Live preview
Madrid
Lisbon
Paris
Rome

Events: 0 ยท

Generated template: reflects the settings above. Imports and state are in the Code tab.

template.html
<neu-listbox
  (optionActivated)="record('optionActivated', $event)"
  (filterChange)="onFilterChange($event)"
  (dataRequest)="record('dataRequest', $event)"
  (rangeChange)="record('rangeChange', $event)"
  (focusEntered)="record('focusEntered', $event)"
  (focusLeft)="record('focusLeft', $event)"
  (touch)="record('touch', $event)"
  (drop)="record('drop', $event)"
  (valueChange)="record('valueChange', $event)"
  [options]="destinations"
  [(value)]="destination"
  [searchable]="true"
  [ariaFilterLabel]="'Search destinations'"
  [checkbox]="true"
  [emptyLabel]="'No destinations'"
  [fluid]="true"
  [label]="'Destination'"
  [noResultsMessage]="'No matches'"
  [searchPlaceholder]="'Search'"
/>

Value and events

Use one source of truth: [(value)]="destination" or [value]="destination()" with (valueChange)="destination.set($event)". Do not bind both forms at once.

Inputs configure the control. valueChange synchronizes its model; the other Outputs report their documented actions or lifecycle. Requests for suggestions, children or remote windows require the application to supply data.

Accessibility and keyboard

Use a visible label or an accessible name. Test keyboard navigation, disabled options, selection and closing the panel. Custom option templates should keep descriptive text and must not introduce a nested button or another focusable checkbox inside the option.

Key
Action
Tab Moves focus into or out of the control.
ArrowDown / ArrowUp Moves the active option through available options.
Enter Activates the focused option.

API

The reference lists the public Inputs, models, Outputs and Templates from the pinned Core package. Click a named type to open its definition. Each applicable Template has an executable example and its actual source.

Inputs

Configure the component with [property]="value". Your application supplies these values; the component does not replace the state you pass in.

Name
Type
Default
Template binding
Description
ariaDescribedBystring | nullnull[ariaDescribedBy]IDs of elements describing the control, separated by spaces.
ariaFilterLabelstring'Filter options'[ariaFilterLabel]Accessible name of the option search field.
ariaLabelstring'Options'[ariaLabel]Accessible name when no visible label is available.
ariaLabelledBystring | nullnull[ariaLabelledBy]ID of the element that supplies the accessible name.
autoOptionFocusbooleantrue[autoOptionFocus]Moves the active option to an available option when the list opens.
checkboxbooleanfalse[checkbox]Displays checkbox indicators for multiple selection.
checkmarkbooleanfalse[checkmark]Displays a checkmark next to selected options.
compareWith(left: V, right: V) => booleanObject.isDerived default[compareWith]Comparison function for selected values; use stable domain identity.
dataFirstnumber0[dataFirst]Logical index of the first loaded option in a remote window.
dirtybooleanfalse[dirty]Form state indicating that the user has changed the value.
disabledbooleanfalse[disabled]Disables user interaction; disabled options cannot be selected.
dragdropbooleanfalse[dragdrop]Enables drag-and-drop between compatible listboxes.
emptyLabelstring'No options found'[emptyLabel]Message displayed when there are no available options.
errorsreadonly ValidationError.WithOptionalFieldTree[][][errors]Validation errors supplied by the form or the application.
filterConfigReadonly<NeuOptionFilterConfig<T>>{}[filterConfig]Fields, matching mode, locale and client/server filtering strategy.
filterValuestring | nullnull[filterValue]Applied search query. Listen to filterChange when the application controls it.
fluidbooleanfalse[fluid]Makes the control fill its containing width.
focusOnHoverbooleantrue[focusOnHover]Changes the active option when the pointer enters an option.
groupConfigNeuOptionGroupConfig<T, G> | nullnull[groupConfig]Accessors used to read group labels, children and disabled state.
groupsreadonly G[][][groups]Grouped options, with child items configured through groupConfig.
hiddenbooleanfalse[hidden]Hides the control according to the form state.
highlightOnSelectbooleantrue[highlightOnSelect]Highlights selected option rows.
hintstring''[hint]Help text associated with the field.
idstring | nullnull[id]Identifier of the control host.
invalidbooleanfalse[invalid]Displays the invalid state; it does not add a validation rule.
labelstring''[label]Visible field or option label.
lazybooleanfalse[lazy]Uses loaded windows and emits requests for missing option data.
listStyleRecord<string, string | number> | nullnull[listStyle]Inline styles for the list viewport.
listStyleClassstring | nullnull[listStyleClass]Additional CSS class for the list viewport.
loadingbooleanfalse[loading]Displays the loading state while the application supplies data.
metaKeySelectionbooleanfalse[metaKeySelection]Controls whether selection uses the platform modifier key.
modeM'single' as MDerived default[mode]Selection mode. The accepted value shape follows the chosen mode.
namestring''[name]Name associated with the native form control.
noResultsMessagestring'No results found'[noResultsMessage]Message displayed when filtering produces no matches.
optionDisabledNeuOptionDisabledAccessor<T> | nullnull[optionDisabled]Field name or function that marks an option as disabled.
optionLabelNeuOptionLabelAccessor<T> | nullnull[optionLabel]Field name or function used to obtain the visible option label.
optionsreadonly T[][][options]Loaded option records. Accessors allow using your own domain objects.
optionValue(option: T) => V(option) => resolveNeuOptionValue<T, V>(option)Derived default[optionValue]Field name or function used to obtain the stored option value.
pendingbooleanfalse[pending]Form state indicating that asynchronous validation is pending.
readonlybooleanfalse[readonly]Keeps the value readable without allowing the user to change it.
requiredbooleanfalse[required]Marks the field as required; use a form validator to enforce it.
scrollHeightstring'18rem'[scrollHeight]Maximum height of the option viewport.
searchablebooleanfalse[searchable]Displays the built-in option search field.
searchPlaceholderstring'Search...'[searchPlaceholder]Placeholder for the option search field.
selectOnFocusbooleanfalse[selectOnFocus]Selects the option as focus moves, rather than waiting for activation.
showToggleAllbooleantrue[showToggleAll]Shows the toggle-all action in checkbox multiple mode.
stripedbooleanfalse[striped]Alternates option row backgrounds.
tabindexnumber0[tabindex]Tab order of the keyboard entry point.
toggleAllLabelstring'Select all visible options'[toggleAllLabel]Accessible and visible name of the toggle-all action.
totalItemsnumber | nullnull[totalItems]Logical total option count for remote windows.
touchedbooleanfalse[touched]Form state indicating that the control has been visited.
virtualScrollbooleanfalse[virtualScroll]Renders an option window instead of every option.
virtualScrollBuffernumber3[virtualScrollBuffer]Extra options rendered before and after the visible virtual window.
virtualScrollItemSizenumber40[virtualScrollItemSize]Measured option row height in pixels for virtual scrolling.
virtualScrollViewportItemsnumber8[virtualScrollViewportItems]Number of rows in the virtual viewport.

Models

A model supports [(property)]="signal" or the [property] and (propertyChange) pair. Choose one form, not both.

Name
Type
Default
Template binding
Description
valueNeuSelectionValue<V, M>null as NeuSelectionValue<V, M>Derived default[(value)]Single mode: one value or null. Multiple mode: an array. The application owns the bound model.

Outputs

Listen to an event with (event)="handler($event)". The table explains the data your handler receives and how to use it.

Name
Payload
Template binding
Description
dataRequestNeuOptionDataRequest(dataRequest)="onDataRequest($event)"Requests an option window. The application supplies options, dataFirst and totalItems.
dropNeuListboxDropEvent<T>(drop)="onDrop($event)"Drag-and-drop result. Apply the reordered options in the application.
filterChangestring(filterChange)="onFilterChange($event)"User search query. Use it to update a controlled filter or request remote results.
focusEnteredFocusEvent(focusEntered)="onFocusEntered($event)"Emitted when focus enters the control.
focusLeftFocusEvent(focusLeft)="onFocusLeft($event)"Emitted when focus leaves the control.
optionActivatedNeuOptionActivatedEvent<T, V>(optionActivated)="onOptionActivated($event)"Activated option, its value and the originating event.
rangeChangeNeuViewportRange(rangeChange)="onRangeChange($event)"Current visible virtual viewport range.
touchvoid(touch)="onTouch($event)"Notifies the form that the control has been touched; not a value change.

Templates

ng-content projects content into the component. TemplateRef inputs receive a template; ng-template directives identify templates with a typed context. A directive shared by an entrypoint is not necessarily a slot of this component.

Name
Mechanism
Contract
NeuListboxEmptyDirectiveView example Public template directive (entrypoint)ng-template[neuListboxEmpty]
NeuListboxEmptyFilterDirectiveView example Public template directive (entrypoint)ng-template[neuListboxEmptyFilter]
NeuListboxFilterDirectiveView example Public template directive (entrypoint)ng-template[neuListboxFilter]
NeuListboxFooterDirectiveView example Public template directive (entrypoint)ng-template[neuListboxFooter]
NeuListboxGroupDirectiveView example Public template directive (entrypoint)ng-template[neuListboxGroup]
NeuListboxHeaderDirectiveView example Public template directive (entrypoint)ng-template[neuListboxHeader]
NeuListboxIndicatorDirectiveView example Public template directive (entrypoint)ng-template[neuListboxIndicator]
NeuListboxItemDirectiveView example Public template directive (entrypoint)ng-template[neuListboxItem]
NeuListboxLoaderDirectiveView example Public template directive (entrypoint)ng-template[neuListboxLoader]

Each example demonstrates a different template. Switch between Demo and Code to inspect its implementation, imports and state.

Empty template

NeuListboxEmptyDirective

Empty template

Open the control to see the empty state.

No destinations are available yet.

EmptyFilter template

NeuListboxEmptyFilterDirective

EmptyFilter template

The template below replaces only its named region.

No matches. Try another search.

Filter template

NeuListboxFilterDirective

Filter template

The template below replaces only its named region.

Madrid
Lisbon
Paris
Rome

Group template

NeuListboxGroupDirective

Group template

The template below replaces only its named region.

Madrid
Lisbon
Paris
Rome

Header template

NeuListboxHeaderDirective

Header template

The template below replaces only its named region.

Choose your next destination

Madrid
Lisbon
Paris
Rome

Indicator template

NeuListboxIndicatorDirective

Indicator template

The template below replaces only its named region.

Madrid
Lisbon
Paris
Rome

Item template

NeuListboxItemDirective

Item template

The template below replaces only its named region.

Madrid
Lisbon
Paris
Rome

Loader template

NeuListboxLoaderDirective

Loader template

The template below replaces only its named region.

Public methods

Name
Contract
resetFilterresetFilter(): void;
setFiltersetFilter(value: string, originalEvent?: Event | null): void;
toggleAlltoggleAll(event: Event): void;

Public Types

Open a type to inspect its definition and interface fields.

Styles and tokens

Load Core styles once. Use the public tokens below for local customization or a preset for application-wide changes. Keep labels, focus, selected options and disabled states readable in both light and dark themes.

Specific tokens

This component uses shared theme tokens rather than dedicated component hooks.

Shared tokens used

Override these on a local wrapper to affect this example. An override on :root affects other components that use the same token.

Token
Purpose here
Other impact
Default / fallback
--neu-border Normal control and cell borders Shared by other Core consumers; scope the override. rgba(15, 23, 42, 0.08)
--neu-error Invalid field or danger-action color Shared by other Core consumers; scope the override. #dc2626
--neu-primary Brand color for active controls and emphasis Shared by other Core consumers; scope the override. #007aff
--neu-surface Main field, header or control surface Shared by other Core consumers; scope the override. #ffffff
--neu-text Main text and inherited icon color Shared by other Core consumers; scope the override. #0f172a
--neu-text-muted Secondary labels and supporting content Shared by other Core consumers; scope the override. #475569