Combobox
An accessible typeable autocomplete with consumer-driven filtering.
Basic Combobox
Type to filter, use Up / Down to navigate, Enter to select, Escape to close.
The combobox emits an OnQueryChange event; you do the filtering
in your own code and pass only the matching options as children.
Multi-select with chips
Set Multiple="true" to allow many selections. Selected values are
shown as chips before the input (each with a remove button). The panel stays
open after each pick.
Creatable values and a clear button
With CreateValue, Enter on text that matches no option makes a new value of it and raises
OnCreate - add it to your options there. A BitBhComboboxClear empties the value and the text
and puts the focus back in the input; it is named "Clear", out of the tab order (Escape does the same) and disabled
while there is nothing to clear.
Object values with rich content
Bind to objects rather than strings. Provide a DisplayValue function
that converts the selected object back to the input text, and render rich content
inside each option.
Anchor Positioning
Set Anchor on BitBhComboboxOptions to automatically position
the dropdown relative to the input using position: fixed. The panel
flips to the opposite side when there's not enough space, shifts to stay within
the viewport, and auto-updates on scroll/resize. No position: relative
on the parent is needed.
Bottom Start
Top Start (flips down if no space)
Large lists (virtualized)
Pass the matching data to BitBhComboboxOptions through Items with an
ItemTemplate, and set Virtualize="true" so only the options in view
are rendered in a scrollable panel. Every option must be exactly ItemSize tall
(36px here): the CSS version sizes the generated [role="option"] elements, the
Tailwind version gives the template's content h-9. Filtering stays yours:
OnQueryChange runs BitBhFilter.Contains — case- and
accent-insensitive — over 10,000 items on every keystroke. Child content such as
BitBhComboboxEmpty still renders after the data options; it shows only while
nothing matches.
Options of different heights (virtualized)
With VariableItemSize="true" the options of a virtualized panel can differ in height - here
each article shows an excerpt of one to three lines. Every option is measured as it renders and again when
it resizes; ItemSize (60px here) is only the estimate for the options not rendered yet, and a
new query starts over with the matches it found. The scroll position holds still as measurements arrive,
and the arrow keys and Page Up / Page Down keep the highlighted option fully in view.
- Accessibility basics 1 A short read.
- Animations basics 1 A complete example, from the first render to the last test, with the trade-offs of every step and the mistakes that are easy to make along the way.
- Caching basics 1 What changes between versions, and what to update first in an existing app.
- Forms basics 1 A short read.
- Keyboard basics 1 A complete example, from the first render to the last test, with the trade-offs of every step and the mistakes that are easy to make along the way.
- Layout basics 1 What changes between versions, and what to update first in an existing app.
- Routing basics 1 A short read.
- Testing basics 1 A complete example, from the first render to the last test, with the trade-offs of every step and the mistakes that are easy to make along the way.
- Theming basics 1 What changes between versions, and what to update first in an existing app.
- Virtualization basics 1 A short read.
- Accessibility deep dive 1 A complete example, from the first render to the last test, with the trade-offs of every step and the mistakes that are easy to make along the way.
- Animations deep dive 1 What changes between versions, and what to update first in an existing app.
- Caching deep dive 1 A short read.
- Forms deep dive 1 A complete example, from the first render to the last test, with the trade-offs of every step and the mistakes that are easy to make along the way.
- Keyboard deep dive 1 What changes between versions, and what to update first in an existing app.
- Layout deep dive 1 A short read.
- Routing deep dive 1 A complete example, from the first render to the last test, with the trade-offs of every step and the mistakes that are easy to make along the way.
- Testing deep dive 1 What changes between versions, and what to update first in an existing app.
- Theming deep dive 1 A short read.
- Virtualization deep dive 1 A complete example, from the first render to the last test, with the trade-offs of every step and the mistakes that are easy to make along the way.