DesignOverviewDesign SystemMapsGraphIntroductionInstallationDeriving a themeSandboxTheme builderVisual testingAgentsCortexMemoryActiveProvenanceActiveContextActiveServicesInsightsGet in touchSource on GitHub
Loading the reference
ListboxView sourceEdit in SandboxView MarkdownCopy MarkdownOpen in ClaudeOpen in CursorA list of options, from which you choose one or several.Also called Options and Select list.StableSince 0.1.0FormsImportimport'@fusion.dev/helix/listbox'import'@fusion.dev/helix-headless/listbox'Preview
GuidelinesWhen to use
A list of options that stays open on the page.ListboxThis page
Import Option beside Listbox, for options you write and for items alike.An option belongs to the Option family, which Listbox does not register.
Import @fusion.dev/helix/listbox/reorder to set reorderable.Moving options is a separate import, so a list that never moves options carries none of its code.
Move the options yourself after a reorder, or set items in the new order.The list moves no element of yours, and the reorder event holds every value in the new order.
Anatomy
1::part(label)The label above the list.
2::part(items)The list of options.
3::part(hint)OptionalHelp under the list.
API referenceRoothelix-listboxA list of options, from which you choose one or several.
PropTypeDescriptionautocompletestringDefault"off"What a browser's autofill may choose, as a platform token such as
country or cc-exp-month, as a native <select> takes it.bleed"none"Whether a highlighted row is drawn as a fill inset from the panel's edge.defaultFilterstringDefault""The filter text the list starts with, when filter is not set.defaultValuestringDefault""The value the control starts with. A form reset returns it to this value,
and to the value attribute where this one is not written, as a native
control resets to the value it declares.dictationDeniedLabelstringDefault"Dictation needs the microphone"What a screen reader hears when the browser or the reader refuses the microphone.dictationFailedLabelstringDefault"Dictation stopped with an error"What a screen reader hears when listening ends with an error that has no label of its own.dictationUnreachableLabelstringDefault"Dictation could not reach the speech service"What a screen reader hears when the recognizer cannot reach its speech service.disabledbooleanDefaultfalseWhether the control is disabled and cannot be used.emptyTextstringDefault"No options"The text shown and announced when there are no rows and none are loading.errorTextstring|nullDefault""What the list says when its options could not be loaded, such as after a
request to a server fails. Empty, null or no attribute is no error, so
removing the attribute clears it.feedbackstringDefault""The validation message shown under the control. It replaces the
browser's message.filterstringThe text the list is filtered by, if any.filterablebooleanDefaultfalseWhether the list shows a field for filtering it.filterDelaynumberDefault0How long typing in the filter field rests before the list is filtered, in
milliseconds. 0 filters on every keystroke. The attribute also takes a
CSS time, such as 300ms.filterLabelstringDefault"Filter"Placeholder text for the filter field.filterMatch((text: string, filter: string) => boolean)Whether an option is kept by the filter: a function given the option's
words and the filter, trimmed, that returns true to keep it showing, as
React Aria's Autocomplete takes filter. For matching that ignores
accents, matches the start of each word, or matches out of order.hintstringDefault""Help text shown under the control. A validation message replaces it.itemsreadonlyDataOptionItem[]The options as data, for a list too long to draw whole: each a value,
which is also its words, or a record with a value, a label and
disabled. Set, the list draws only the options in sight, and the ones
you write as children are not read.labelstringDefault""The field's label, which is also its accessible name. Content in the
label slot replaces it.layout"grid"|"stack"How the options are laid out, which the arrow keys follow: stack, one
under another, or grid, in rows and columns, as React Aria's ListBox
lays out cards or photos. With grid, Up and Down move within a column,
and Left and Right along the list, mirrored right to left.listeningLabelstringDefault"Listening"What a screen reader hears as listening starts.loadErrorstring|nullThe old name of error-text, read only where a page sets it.loadingbooleanDefaultfalseWhether the rows are still loading.loadingTextstringDefault"Loading"The text shown and announced while the rows load.manualbooleanDefaultfalseStops the arrow keys from choosing each option they move to. Enter, Space
or a click chooses the highlighted option.multiplebooleanDefaultfalseWhether more than one option can be chosen.namestringDefault""The name the control's value is submitted under.noResultsTextstringDefault"No matches"The text shown when a filter hides every option of a list that has some.
empty-text is what a list with no options says.reorderablebooleanDefaultfalseLets a reader move options, once @fusion.dev/helix/listbox/reorder (or
@fusion.dev/helix-headless/listbox/reorder) is imported: Alt with an
arrow moves the highlighted option, and a pointer drags one. The list
moves no option itself: you move your options, or your items, on
helix-reorder. Without that import it does nothing, so a list that never
moves options carries none of the code.requiredbooleanDefaultfalseWhether the field needs a value before the form can submit.resultLabelstringWhat a screen reader hears when a filter leaves one option, where
results-label should not say it. {count} is the count.resultsLabelstringDefault"{count, plural, one {# result} other {# results}}"What a screen reader hears when a filter narrows the list. {count} is
how many options are left, written in the locale, and each language
writes the forms it has: {count, plural, one {# wynik} few {# wyniki} many {# wyników} other {# wyniku}}.selectedIndexnumberWhich option is chosen, as an index, or -1 where none is.selectedLabelstringDefault"{name}, selected"What VoiceOver hears as the highlight reaches a chosen option from the
filter field, on Apple devices. {name} is the option's words.speechEngineSpeechEngineThe engine this field listens through, in place of the one
registerSpeechEngine gave the page, or the browser's own.stoppedListeningLabelstringDefault"Stopped listening"What a screen reader hears as listening stops.valuestringThe control's current value, which its form submits.valueMissingMessagestringDefault"Choose one to continue."The message shown when the field is required and empty.voicebooleanDefaultfalseDraws a button that listens for dictation and types what it hears at
the caret. Nothing listens until the button is pressed, and the
microphone is let go as listening stops. An input of type password,
email or number draws no button.voiceLabelstringDefault"Dictate"The dictation button's name while it is not listening.voiceStopLabelstringDefault"Stop dictation"The dictation button's name while it listens.
ReadTypeDescriptionformHTMLFormElement|nullThe form the control belongs to, or null.labelsNodeListThe labels associated with the control.listeningbooleanWhether the field is listening for dictation now.optionsHelixHeadlessOption[]Every option, in the order they appear.typestringThe kind of list, as the platform names it: select-one or
select-multiple.validationMessagestringThe message the browser would show for the control, or an empty string.validityValidityStateWhether the control meets its constraints, and why not.valuesstring[]The chosen values, as an array whether or not multiple is set.whenSettledPromise<void>Resolves a frame after the first update, when transitions are switched on.willValidatebooleanWhether the control is checked when its form is submitted.
SlotDescription(default)The options, and any groups of them.emptyWhat the list shows when it has no options to show, for content richer than empty-text.errorContent shown after error-text while it is set, such as a button that tries again.feedbackThe message that says what is wrong, for content richer than a string. It shows while there is a message.filter-iconThe icon in the filter field. Defaults to a magnifying glass.hintThe hint, for content richer than plain text.labelThe label, for content richer than plain text.loadingWhat the list shows while its options load, for content richer than loading-text.no-resultsWhat the list shows when a filter hides every option, for content richer than no-results-text.
EventTypeDescriptionchangeEventFired after the value changes.helix-before-changeHelixBeforeChangeEventFired when the value is about to change, and cancelable.helix-before-filterHelixBeforeFilterEventFired before the list is filtered, and cancelable.helix-before-listenHelixBeforeListenEventThe dictation button was pressed. Cancelable: cancel it to keep the field from listening.helix-before-reorderHelixBeforeReorderEventFired when an option is dropped at a new place, in a reorderable list with @fusion.dev/helix/listbox/reorder imported, with every value in the new order. Cancelable: cancel it to keep the option where it is.helix-filterHelixFilterEventFired after the list is filtered, with the text it is filtered by, which filter also holds.helix-listenHelixListenEventDictation settled on a phrase and put it in the search field, after the field's own input.helix-load-moreHelixLoadMoreEventFired once the list is scrolled within a screen of its end, once for each number of options, and not while loading is set. Add the next page of options and set loading while you fetch it.helix-reorderHelixReorderEventFired after helix-before-reorder when nobody canceled it. Move your options, or your items, to the order in keys.inputEventFired after the value changes.
MethodTypeDescriptioncheckValidity() => booleanReturns whether the control is valid, and fires invalid on it when it is
not. The control shows no message for it: reportValidity() does that.focus(options: FocusOptions) => voidMoves focus to the control, as focusing a native control does.highlightValue(value: string) => voidPuts the highlight on the option holding value, without choosing it, so
the arrow keys move from there. Nothing changes where no option a reader
can reach holds value.navigate(event: KeyboardEvent) => voidRuns the list's own key handling for a caller whose focus is elsewhere.reportValidity() => booleanReturns whether the control is valid, and when it is not, fires invalid
and shows the browser's message at the control.requestFilter(next: string) => booleanRequests a new filter, and returns whether the request went through.requestValue(next: string) => booleanRequests a new value, and returns whether the change was applied.reveal() => voidScrolls the chosen option to the middle of the list, or the highlighted one
where nothing is chosen.setCustomValidity(message: string) => voidMarks the control invalid with message, or clears that with an empty
string, as on a native control. The form does not submit while it is set.startListening() => booleanStarts listening, as pressing the dictation button does, and returns
whether it did. It does not where voice drew no button, where the
field has nowhere to type, or where a listener refused
helix-before-listen.stopListening() => voidStops listening, keeping what was heard in the field.
PartDescriptionemptyThe text shown when the list has no options to show, or the filter hides every one. :state(no-results) is set for the second.errorThe text shown while error-text is set, followed by the error slot.feedbackThe message that says what is wrong with the value.filter-iconThe icon beside the filter field.filter-markThe default icon beside the filter field, shown when none is slotted.hintHelp under the list.itemsThe list of options.labelThe label above the list.liveA copy of the empty and loading text, how many options a filter left, and each move in a reorderable list, in a region that screen readers announce when it changes. Visually hidden in the styled tier.loadingThe text shown while the options load.searchThe region that holds the filter field.search-fieldThe filter field.voiceThe dictation button, under voice on a filterable list, in the search field.voice-levelThe meter that draws the microphone's level in place of its glyph while the field listens, where the tier defines Voice Level.voice-level-canvasThe canvas the dictation meter draws on.voice-listeningThe dictation button while it listens. Set alongside voice.voice-statusWhat a screen reader hears as dictation starts and stops, drawn for no one else.
CSS PropertyDescription--listbox-background-colorThe panel's fill. Set it to transparent when the list is already inside a panel.--listbox-bleedHow far a option's fill reaches past its words unless bleed is none. Defaults to --helix-space-row-bleed, which follows the density.--listbox-borderThe panel's border, as a shorthand. Set it to none when the list is already inside a panel.--listbox-column-min-inline-sizeHow narrow a column may be with layout="grid". As many columns as fit are drawn. Defaults to 8rem.--listbox-drag-preview-background-colorThe fill behind the copy of an option a pointer drags.--listbox-drag-preview-border-colorThe color of the edge around the copy of an option a pointer drags.--listbox-drag-preview-border-widthThe width of the edge around the copy of an option a pointer drags. None by default, where the shadow lifts it.--listbox-drag-preview-opacityThe opacity of the copy of an option a pointer drags.--listbox-drag-preview-radiusThe corner radius of the copy of an option a pointer drags.--listbox-drag-preview-shadowThe shadow that raises the copy of an option a pointer drags over the page.--listbox-dragging-opacityThe opacity of an option being dragged, in a reorderable list with @fusion.dev/helix/listbox/reorder imported.--listbox-drop-indicator-colorThe color of the line where a dragged option would land.--listbox-drop-indicator-sizeThe thickness of the line where a dragged option would land.--listbox-error-colorThe color of the line shown while error-text is set.--listbox-max-block-sizeMaximum height of the list before it scrolls.
Custom stateDescriptionemptyThe list has no options to show: none were given, or the filter hid every one.errorWhile error-text is set.invalidThe control has an error to show, from the browser's validation or from your feedback.listeningWhile the field listens for dictation. The element sets --dictation-level on itself meanwhile, from 0 to 1, for a meter.loadingWhile loading is set.no-resultsA filter hid every option of a list that has some.settledSet one frame after the first render. Transitions wait for it, so an element does not animate its own arrival.
Roothelix-headless-listboxA list of options, from which you choose one or several.
PropTypeDescriptionautocompletestringDefault"off"What a browser's autofill may choose, as a platform token such as
country or cc-exp-month, as a native <select> takes it.defaultFilterstringDefault""The filter text the list starts with, when filter is not set.defaultValuestringDefault""The value the control starts with. A form reset returns it to this value,
and to the value attribute where this one is not written, as a native
control resets to the value it declares.dictationDeniedLabelstringDefault"Dictation needs the microphone"What a screen reader hears when the browser or the reader refuses the microphone.dictationFailedLabelstringDefault"Dictation stopped with an error"What a screen reader hears when listening ends with an error that has no label of its own.dictationUnreachableLabelstringDefault"Dictation could not reach the speech service"What a screen reader hears when the recognizer cannot reach its speech service.disabledbooleanDefaultfalseWhether the control is disabled and cannot be used.emptyTextstringDefault"No options"The text shown when the list has no options. A filter that hides every
option shows no-results-text.errorTextstring|nullDefault""What the list says when its options could not be loaded, such as after a
request to a server fails. Empty, null or no attribute is no error, so
removing the attribute clears it.feedbackstringDefault""The validation message shown under the control. It replaces the
browser's message.filterstringThe text the list is filtered by, if any.filterablebooleanDefaultfalseWhether the list shows a field for filtering it.filterDelaynumberDefault0How long typing in the filter field rests before the list is filtered, in
milliseconds. 0 filters on every keystroke. The attribute also takes a
CSS time, such as 300ms.filterLabelstringDefault"Filter"Placeholder text for the filter field.filterMatch((text: string, filter: string) => boolean)Whether an option is kept by the filter: a function given the option's
words and the filter, trimmed, that returns true to keep it showing, as
React Aria's Autocomplete takes filter. For matching that ignores
accents, matches the start of each word, or matches out of order.hintstringDefault""Help text shown under the control. A validation message replaces it.itemsreadonlyDataOptionItem[]The options as data, for a list too long to draw whole: each a value,
which is also its words, or a record with a value, a label and
disabled. Set, the list draws only the options in sight, and the ones
you write as children are not read.labelstringDefault""The field's label, which is also its accessible name. Content in the
label slot replaces it.layout"grid"|"stack"How the options are laid out, which the arrow keys follow: stack, one
under another, or grid, in rows and columns, as React Aria's ListBox
lays out cards or photos. With grid, Up and Down move within a column,
and Left and Right along the list, mirrored right to left.listeningLabelstringDefault"Listening"What a screen reader hears as listening starts.loadErrorstring|nullThe old name of error-text, read only where a page sets it.loadingbooleanDefaultfalseWhether the rows are still loading.loadingTextstringDefault"Loading"The text shown and announced while the rows load.manualbooleanDefaultfalseStops the arrow keys from choosing each option they move to. Enter, Space
or a click chooses the highlighted option.multiplebooleanDefaultfalseWhether more than one option can be chosen.namestringDefault""The name the control's value is submitted under.noResultsTextstringDefault"No matches"The text shown when a filter hides every option of a list that has some.
empty-text is what a list with no options says.reorderablebooleanDefaultfalseLets a reader move options, once @fusion.dev/helix/listbox/reorder (or
@fusion.dev/helix-headless/listbox/reorder) is imported: Alt with an
arrow moves the highlighted option, and a pointer drags one. The list
moves no option itself: you move your options, or your items, on
helix-reorder. Without that import it does nothing, so a list that never
moves options carries none of the code.requiredbooleanDefaultfalseWhether the field needs a value before the form can submit.resultLabelstringWhat a screen reader hears when a filter leaves one option, where
results-label should not say it. {count} is the count.resultsLabelstringDefault"{count, plural, one {# result} other {# results}}"What a screen reader hears when a filter narrows the list. {count} is
how many options are left, written in the locale, and each language
writes the forms it has: {count, plural, one {# wynik} few {# wyniki} many {# wyników} other {# wyniku}}.selectedIndexnumberWhich option is chosen, as an index, or -1 where none is.selectedLabelstringDefault"{name}, selected"What VoiceOver hears as the highlight reaches a chosen option from the
filter field, on Apple devices. {name} is the option's words.speechEngineSpeechEngineThe engine this field listens through, in place of the one
registerSpeechEngine gave the page, or the browser's own.stoppedListeningLabelstringDefault"Stopped listening"What a screen reader hears as listening stops.valuestringThe control's current value, which its form submits.valueMissingMessagestringDefault"Choose one to continue."The message reported when the field is required and no option is chosen.
Absent, or empty, is this sentence, or the words registered for the page's
locale.voicebooleanDefaultfalseDraws a button that listens for dictation and types what it hears at
the caret. Nothing listens until the button is pressed, and the
microphone is let go as listening stops. An input of type password,
email or number draws no button.voiceLabelstringDefault"Dictate"The dictation button's name while it is not listening.voiceStopLabelstringDefault"Stop dictation"The dictation button's name while it listens.
ReadTypeDescriptionformHTMLFormElement|nullThe form the control belongs to, or null.labelsNodeListThe labels associated with the control.listeningbooleanWhether the field is listening for dictation now.optionsHelixHeadlessOption[]Every option, in the order they appear.typestringThe kind of list, as the platform names it: select-one or
select-multiple.validationMessagestringThe message the browser would show for the control, or an empty string.validityValidityStateWhether the control meets its constraints, and why not.valuesstring[]The chosen values, as an array whether or not multiple is set.whenSettledPromise<void>Resolves a frame after the first update, when transitions are switched on.willValidatebooleanWhether the control is checked when its form is submitted.
SlotDescription(default)The options, and any groups of them.emptyWhat the list shows when it has no options to show, for content richer than empty-text.errorContent shown after error-text while it is set, such as a button that tries again.feedbackThe message that says what is wrong, for content richer than a string. It shows while there is a message.filter-iconThe icon in the filter field. Defaults to a magnifying glass.hintThe hint, for content richer than plain text.labelThe label, for content richer than plain text.loadingWhat the list shows while its options load, for content richer than loading-text.no-resultsWhat the list shows when a filter hides every option, for content richer than no-results-text.
EventTypeDescriptionchangeEventFired after the value changes.helix-before-changeHelixBeforeChangeEventFired when the value is about to change, and cancelable.helix-before-filterHelixBeforeFilterEventFired before the list is filtered, and cancelable.helix-before-listenHelixBeforeListenEventThe dictation button was pressed. Cancelable: cancel it to keep the field from listening.helix-before-reorderHelixBeforeReorderEventFired when an option is dropped at a new place, in a reorderable list with @fusion.dev/helix/listbox/reorder imported, with every value in the new order. Cancelable: cancel it to keep the option where it is.helix-filterHelixFilterEventFired after the list is filtered, with the text it is filtered by, which filter also holds.helix-listenHelixListenEventDictation settled on a phrase and put it in the search field, after the field's own input.helix-load-moreHelixLoadMoreEventFired once the list is scrolled within a screen of its end, once for each number of options, and not while loading is set. Add the next page of options and set loading while you fetch it.helix-reorderHelixReorderEventFired after helix-before-reorder when nobody canceled it. Move your options, or your items, to the order in keys.inputEventFired after the value changes.
MethodTypeDescriptioncheckValidity() => booleanReturns whether the control is valid, and fires invalid on it when it is
not. The control shows no message for it: reportValidity() does that.focus(options: FocusOptions) => voidMoves focus to the control, as focusing a native control does.highlightValue(value: string) => voidPuts the highlight on the option holding value, without choosing it, so
the arrow keys move from there. Nothing changes where no option a reader
can reach holds value.navigate(event: KeyboardEvent) => voidRuns the list's own key handling for a caller whose focus is elsewhere.reportValidity() => booleanReturns whether the control is valid, and when it is not, fires invalid
and shows the browser's message at the control.requestFilter(next: string) => booleanRequests a new filter, and returns whether the request went through.requestValue(next: string) => booleanRequests a new value, and returns whether the change was applied.reveal() => voidScrolls the chosen option to the middle of the list, or the highlighted one
where nothing is chosen.setCustomValidity(message: string) => voidMarks the control invalid with message, or clears that with an empty
string, as on a native control. The form does not submit while it is set.startListening() => booleanStarts listening, as pressing the dictation button does, and returns
whether it did. It does not where voice drew no button, where the
field has nowhere to type, or where a listener refused
helix-before-listen.stopListening() => voidStops listening, keeping what was heard in the field.
PartDescriptionemptyThe text shown when the list has no options to show, or the filter hides every one. :state(no-results) is set for the second.errorThe text shown while error-text is set, followed by the error slot.feedbackThe message that says what is wrong with the value.filter-iconThe icon beside the filter field.filter-markThe default icon beside the filter field, shown when none is slotted.hintHelp under the list.itemsThe list of options.labelThe label above the list.liveA copy of the empty and loading text, how many options a filter left, and each move in a reorderable list, in a region that screen readers announce when it changes. Visually hidden in the styled tier.loadingThe text shown while the options load.searchThe region that holds the filter field.search-fieldThe filter field.voiceThe dictation button, under voice on a filterable list, in the search field.voice-levelThe meter that draws the microphone's level in place of its glyph while the field listens, where the tier defines Voice Level.voice-level-canvasThe canvas the dictation meter draws on.voice-listeningThe dictation button while it listens. Set alongside voice.voice-statusWhat a screen reader hears as dictation starts and stops, drawn for no one else.
Custom stateDescriptionemptyThe list has no options to show: none were given, or the filter hid every one.errorWhile error-text is set.invalidThe control has an error to show, from the browser's validation or from your feedback.listeningWhile the field listens for dictation. The element sets --dictation-level on itself meanwhile, from 0 to 1, for a meter.loadingWhile loading is set.no-resultsA filter hid every option of a list that has some.settledSet one frame after the first render. Transitions wait for it, so an element does not animate its own arrival.
Examples
NameDescriptionBleedA listbox with bleed: its words stay on the field's column, and the fill under a pointer or the keyboard is a rounded inset around them.Controlled filterFilter text set by your code, for a list narrowed from a search box outside it.EventsFiltering sends helix-before-filter, and choosing an option sends helix-before-change, input, and change.FilterableA search field above the list that narrows it as you type.GridOptions in rows and columns, which the arrow keys follow.Loading and emptyA list that is loading, and a list with no options that match the filter, each with its own text.Long listTen thousand options given as data, of which only those in sight are drawn.MultipleSeveral options chosen at once.PreviewA list to choose one from, always open.PreviewA list to choose one from, always open.StatesA disabled list, a list disabled by its fieldset, a list with feedback that says no option is chosen, and a required list in a form.TilesOptions drawn as tiles, each an image with its label under it.