Raft Design System

Components · Inputs

Combobox

A searchable list of values built from parts, for filters with search and for picking a few of many values as chips.

Stable
import { Combobox } from "@botiverse/raft-ui";

A combobox is a list of values that people narrow down by typing. raft-ui gives it as parts: a filter that opens a list with a search row, a field that people type into, or a field of chips for several values. For a ready-made field driven by an array of options, use ComboboxSelect.

combobox/compositions/tasks-channel-filter

When to use

The full choice between pickers is in Choosing a component.

SituationUse
A filter over a list with many values, such as channelsCombobox with ComboboxTrigger and a search row
A few of many values (people, agents, labels) as chips in a fieldCombobox with ComboboxChips
One or a few of many values in a form, from an array of optionsComboboxSelect
An always-open list where choosing a row costs something, such as asking the server about itCombobox with inline open (Inline list)
One of up to 10 valuesSelect

Anatomy

  • Combobox: the root. Holds the value, the typed text and the open state. Required.
  • What opens the list, one of (an inline list is always open, and its ComboboxControl is only the search field):
    • ComboboxTrigger: the filter button, with an icon, a label, ComboboxTriggerCount and ComboboxTriggerIndicator;
    • ComboboxControl: a field at the control height (44px on a phone, 34px on a desktop) with an ink border, holding ComboboxInput, ComboboxClear and ComboboxTriggerIndicator;
    • ComboboxChips: a field at least the control height, holding one ComboboxChip per chosen value, each with a ComboboxChipRemove, then ComboboxInput.
  • ComboboxContent: the popup. Required.
  • ComboboxHeader: the popup's top row, with ComboboxLabel and a ComboboxClear. ComboboxSeparator is the hairline under it.
  • ComboboxInputGroup: the search row at the top of the list, holding ComboboxInput.
  • ComboboxList: the scrolling list of ComboboxItems, each with a ComboboxItemIndicator (the check mark). ComboboxGroup and ComboboxGroupLabel group them; ComboboxRow and ComboboxCollection lay out grids and nested collections.
  • ComboboxEmpty: the line shown when nothing matches.
  • ComboboxValue, ComboboxPortal, ComboboxPopup: lower-level parts.

Variants

VariantUse for
Filter (ComboboxTrigger)Filtering a list: the look of a filter is in Select › Filters
Field (ComboboxControl)Typing to find one value in a form
Chips (ComboboxChips with multiple)A few of many values, shown as chips in the field
Inline list (inline open)An always-open list in a dialog, where the arrow keys move a highlight and Enter or a click chooses
picker-trigger-button/compositions/combobox-filter

Inline list

An inline list is always open, in the page or dialog rather than in a popup: <Combobox inline open>, with a ComboboxControl to search it and a ComboboxList under it, no ComboboxContent. Use it where choosing a row starts something, such as asking the server who in that conversation can't see a file. The arrow keys move the highlight through the rows while focus stays in the search field, and only Enter or a click chooses one, so that work happens once, for the row chosen. A ChoiceList chooses the row the arrow keys reach, as a radio group does, and would start it for every row passed.

combobox/compositions/inline-list
  • Pass open with inline: the list is always shown. Inside a Dialog, leave open fixed rather than binding it to the dialog's open state: the dialog unmounts the list when it closes.
  • Name the list with aria-labelledby on ComboboxList, pointing at the heading above it (Recent, Results).
  • Show what was chosen the way the rest of the screen does (the commit button's label, a summary beside the list): ComboboxItemIndicator and data-selected mark it in the list.
  • To filter with your own search (ranked, from the server), pass filter={null}, the rows to show as items, and control inputValue. Choosing a row leaves the search text as it was.

States

  • Applied filter: a ComboboxTrigger with a value fills with info-soft and shows the count.
  • No match: ComboboxEmpty says what found nothing: No one matches "zz".
  • Focus: a chips field rings as a whole (States); the search row in the popup takes the inset ink outline (Elevation).

Behavior

  • Filter the list as people type.
  • Show ComboboxEmpty when nothing matches. Never leave an empty popup open.
  • With multiple, keep the list open when a value is chosen. Clicking outside or Esc closes it.
  • Make a chosen value a chip on fill-muted, with a remove button at its end. Typing continues after the last chip.
  • A chip sits 6px inside the field's outer edge and 6px from the next one, so it is 22px on a desktop and 32px on a phone and the field keeps the control height until the chips wrap. It wears radius-chip, like every chip; its remove button wears radius-sticker 2px inside the chip, and its focus ring is drawn inside it, where the chip would clip one outside. The clear button in a field is 6px from the field's end, with radius-chip (Shape).
  • Put a chip's text in an element of its own (a <span>): a long value truncates there, at the width of the field, with its whole text as the chip's title, and the remove button stays visible (Forms).
  • A value too long for the input ends in an ellipsis while people aren't typing in it, with its whole text as the input's title (Forms). While they type, it scrolls as in any input, with no title.
  • An item is as tall as its content: one line is 36px, and each further line adds only its own height, with the same space above and below the text (Forms).
  • A long item wraps onto as many lines as it needs. The list grows to fit it up to 24rem (or the field's width, when that is wider), never past the screen less 8px on each side.
  • The list stays on the side it opens on and shrinks to the room there, scrolling, as long as that room holds five options (--popup-list-min-height). Only with less does it flip to the other side, and it opens beside its field only when neither side holds five options (Elevation).
  • The list keeps clear of the frame insets: where a shell keeps part of the window for itself (--raft-frame-inset-top, --raft-frame-inset-start, --raft-frame-inset-end), it stops 8px from that part, not from the window's edge. The start and end insets are the corners of the top band, so they count only when its trigger is in the band; under it, it keeps its own padding from the window's edge (Page structure). The web sets none.
  • In a phone sheet or a drawer the list always stays under the sheet's head: with little room it takes the larger side of the field and scrolls; collisionBoundary="clipping-ancestors" opts it out (Dialog).
  • For results that come from a server, pass filter={null} so the list shows them as they are, and keep the typed text controlled.

Accessibility

Combobox wraps Base UI Combobox: a text input with role="combobox" that controls a listbox, with arrow-key navigation and the highlighted item announced.

  • In an inline list, focus stays in the search field: the highlighted row is its aria-activedescendant, the chosen one has aria-selected="true". Enter on a highlighted row chooses it and doesn't submit the form around it; with no row highlighted, Enter submits as usual. Esc reaches the dialog around the list and closes it.
  • Name the input: with a FieldLabel (Field), or with aria-label on a search row in a popup (Search channels).
  • In a chips field, each chip's remove button and the input are reachable with the keyboard. Name each remove button after its value (Remove Bugen).
  • Give ComboboxClear a label that says what it clears when it shows only an icon.

API

Combobox

PropTypeDefault
actionsRefA ref to imperative actions. - `unmount`: Ends the closing phase of the combobox after an externally controlled closing animation finishes. Call `preventUnmountOnClose()` in `onOpenChange` first, otherwise the combobox completes closing on its own. Whether it leaves the DOM is decided by `keepMounted` on the portal. - `close`: Closes the combobox imperatively when called.RefObject<AriaCombobox.Actions | null>
autoCompleteProvides a hint to the browser for autofill.string
autoHighlightWhether the first matching item is highlighted automatically while filtering.booleanfalse
childrenReactNode
defaultInputValueThe uncontrolled input value when initially rendered.string | number | readonly string[]
defaultOpenWhether the popup is initially open.booleanfalse
defaultValueThe uncontrolled selected value of the combobox when it's initially rendered.NonNullable<Multiple extends true ? readonly Value[] : Value>
disabledWhether the component should ignore user interaction.booleanfalse
filterFilter function used to match items vs input query. Receives the source item, which is the derived value's item when `items` is a `createItems()` collection, and the item itself otherwise.(item: Value, query: string, itemToString?: ((item: Value) => string) | undefined) => boolean
filteredItemsFiltered items to display in the list. When provided, the list uses these items instead of filtering the `items` prop internally. When `items` is also provided, this array must preserve its flat or grouped structure. With a `createItems()` collection, pass source items rather than derived values. Nullish entries are not supported, as in `items`. Use when you want to control filtering logic externally with the `useFilter()` hook.readonly Value[] | readonly Group<Value>[]
formIdentifies the form that owns the internal input. Useful when the combobox is rendered outside the form.string
gridWhether list items are presented in a grid layout. When enabled, arrow keys navigate across rows and columns inferred from DOM rows.booleanfalse
highlightItemOnHoverWhether moving the pointer over items should highlight them. Disabling this prop allows CSS `:hover` to be differentiated from the `:focus` (`data-highlighted`) state.booleantrue
idThe id of the component.string
inlineWhether the list is rendered inline without using the component's own popup.booleanfalse
inputRefA ref to the hidden input element.((instance: HTMLInputElement | null) => void | (() => void | { [UNDEFINED_VOID_ONLY]: never; }) | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<HTMLInputElement | null>
inputValueThe input value of the combobox. Use when controlled.string | number | readonly string[]
isItemEqualToValueCustom comparison logic used to determine if a combobox item value matches the current selected value. Useful when item values are objects without matching referentially. With a `createItems()` collection, both arguments are derived values. Defaults to `Object.is` comparison.(itemValue: Value, value: Value) => boolean
itemsThe items to be displayed in the list. Can be a flat array of items, an array of groups with items, or a collection created by the `createItems()` function, which derives each item's selection value and label. Nullish entries are not supported: remove them from the data before passing it.readonly any[] | readonly Group<any>[] | ComboboxItemCollection<Value, Value>
itemToStringLabelWhen the item values are objects (`<Combobox.Item value={object}>`), this function converts the object value to a string representation for display in the input. If the shape of the object is `{ value, label }`, the label will be used automatically without needing to specify this prop. With a `createItems()` collection, this receives the derived value, and the collection's `getLabel` takes precedence for values it can resolve.(itemValue: Value) => string
itemToStringValueWhen the item values are objects (`<Combobox.Item value={object}>`), this function converts the object value to a string representation for form submission. If the shape of the object is `{ value, label }`, the value will be used automatically without needing to specify this prop. With a `createItems()` collection, this receives the derived value.(itemValue: Value) => string
limitThe maximum number of items to display in the list.number-1
localeThe locale to use for string comparison. Defaults to the user's runtime locale.string | Intl.Locale | readonly (string | Intl.Locale)[]
loopFocusWhether to loop keyboard focus back to the input when the end of the list is reached while using the arrow keys. The first item can then be reached by pressing <kbd>ArrowDown</kbd> again from the input, or the last item can be reached by pressing <kbd>ArrowUp</kbd> from the input. The input is always included in the focus loop per [ARIA Authoring Practices](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/). When disabled, focus does not move when on the last element and the user presses <kbd>ArrowDown</kbd>, or when on the first element and the user presses <kbd>ArrowUp</kbd>.booleantrue
modalDetermines if the popup enters a modal state when open. - `true`: user interaction is limited to the popup: document page scroll is locked and pointer interactions on outside elements are disabled. - `false`: user interaction with the rest of the document is allowed.booleanfalse
multipleWhether multiple items can be selected.NonNullable<Multiple>false
nameIdentifies the field when a form is submitted.string
onInputValueChangeEvent handler called when the input value changes.(inputValue: string, eventDetails: BaseCombobox.Root.ChangeEventDetails) => void
onItemHighlightedCallback fired when an item is highlighted or unhighlighted. Receives the highlighted item value (or `undefined` if no item is highlighted) and event details with a `reason` property describing why the highlight changed. The `reason` can be: - `'keyboard'`: the highlight changed due to keyboard navigation. - `'pointer'`: the highlight changed due to pointer hovering. The event may be a `MouseEvent` rather than a `PointerEvent`. - `'none'`: the highlight changed for another reason, such as typing, `autoHighlight`, the item list changing, or the popup opening or closing.(highlightedValue: Value | undefined, eventDetails: BaseCombobox.Root.HighlightEventDetails) => void
onOpenChangeEvent handler called when the popup is opened or closed.(open: boolean, eventDetails: BaseCombobox.Root.OpenChangeEventDetails) => void
onOpenChangeCompleteEvent handler called after any animations complete when the popup is opened or closed.(open: boolean) => void
onValueChangeEvent handler called when the selected value of the combobox changes.(value: (Multiple extends true ? Value[] : Value) | (Multiple extends true ? never : null), eventDetails: BaseCombobox.Root.ChangeEventDetails) => void
openWhether the popup is currently open. Use when controlled.boolean
openOnInputClickWhether the popup opens when clicking the input.booleantrue
readOnlyWhether the user should be unable to choose a different option from the popup.booleanfalse
requiredWhether the user must choose a value before submitting a form.booleanfalse
valueThe selected value of the combobox. Use when controlled.NonNullable<Multiple extends true ? readonly Value[] : Value>
virtualizedWhether the items are being externally virtualized.booleanfalse

ComboboxChip

PropTypeDefault
size`md` (default): the tag in a Combobox field. `sm`: the 24px tag of a filter (TagFilter)."sm" | "md""md"
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxChipRemove

PropTypeDefault
nativeButtonWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).booleantrue
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxChips

PropTypeDefault
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxClear

PropTypeDefault
disabledWhether the component should ignore user interaction.booleanfalse
keepMountedWhether the component should remain mounted in the DOM when not visible.booleantrue
nativeButtonWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).booleantrue
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxCollection

PropTypeDefault
children (required)(item: any, index: number) => React.ReactNode

ComboboxControl

PropTypeDefault
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxContent

PropTypeDefault
collisionPaddingAdditional space to maintain from the edge of the collision boundary: 8px from the window's edge, and 8px from a frame inset where a shell keeps one. A value you pass is kept as it is.Padding8
portalPropsAutocompletePortalProps
alignHow to align the popup relative to the specified side.Align"start"
alignOffsetAdditional offset along the alignment axis in pixels. Also accepts a function that returns the offset to read the dimensions of the anchor and positioner elements, along with its side and alignment.number | OffsetFunction0
anchorAn element to position the popup against. By default, the popup will be positioned against the trigger.Element | VirtualElement | RefObject<Element | null> | (() => Element | VirtualElement | null)
arrowPaddingMinimum distance to maintain between the arrow and the edges of the popup.number5
collisionAvoidanceDetermines how to handle collisions when positioning the popup.CollisionAvoidanceLIST_POPUP_COLLISION_AVOIDANCE
collisionBoundaryAn element or a rectangle that delimits the area that the popup is confined to.Boundary'clipping-ancestors'
disableAnchorTrackingWhether to disable the popup from tracking any layout shift of its positioning anchor.booleanfalse
finalFocusDetermines the element to focus when the popup is closed.boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null)false
initialFocusDetermines the element to focus when the popup is opened.boolean | RefObject<HTMLElement | null> | ((openType: InteractionType) => void | boolean | HTMLElement | null)false
positionMethodDetermines which CSS `position` property to use."fixed" | "absolute""fixed"
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)
sideWhich side of the anchor element to align the popup against. May automatically change to avoid collisions.Side"bottom"
sideOffsetDistance between the anchor and the popup in pixels. Also accepts a function that returns the distance to read the dimensions of the anchor and positioner elements, along with its side and alignment.number | OffsetFunction0
stickyWhether to maintain the popup in the viewport after the anchor element was scrolled out of view.booleanfalse

Also takes the attributes of its element.

ComboboxEmpty

PropTypeDefault
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxGroup

PropTypeDefault
itemsItems to be rendered within this group. When provided, child `Collection` components will use these items.readonly any[]
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxGroupLabel

PropTypeDefault
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxHeader

Takes the attributes of its element.

ComboboxInput

PropTypeDefault
suppressPasswordManagerboolean
disabledWhether the component should ignore user interaction.booleanfalse
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxInputGroup

PropTypeDefault
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxItem

PropTypeDefault
childrenReactNode
disabledWhether the component should ignore user interaction.booleanfalse
indexThe index of the item in the list. Improves performance when specified by avoiding the need to calculate the index automatically from the DOM.number
nativeButtonWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `true` if the rendered element is a native button.booleanfalse
onClickAn optional click handler for the item when selected. It fires when clicking the item with the pointer, as well as when pressing `Enter` with the keyboard if the item is highlighted when the `Input` or `List` element has focus.(event: BaseUIEvent<MouseEvent<HTMLDivElement, MouseEvent>>) => void
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)
valueA unique value that identifies this item.anynull

Also takes the attributes of its element.

ComboboxItemIndicator

PropTypeDefault
childrenReactNode
keepMountedWhether to keep the HTML element in the DOM when the item is not selected.booleanfalse
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxLabel

PropTypeDefault
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxList

The scrolling list, a ScrollArea container with absolute gutters: the overlay scrollbar lies on a frame around it, since Base UI owns the list's children (items can be a function of each item). The list is never a Tab stop: focus stays in the input, as Base UI manages it.
PropTypeDefault
childrenReactNode | ((item: any, index: number) => React.ReactNode)
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxPopup

Takes the attributes of its element.

ComboboxPortal

PropTypeDefault
containerA parent element to render the portal element into.HTMLElement | ShadowRoot | RefObject<HTMLElement | ShadowRoot | null>
keepMountedWhether to keep the portal mounted in the DOM while the popup is hidden.booleanfalse
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxRow

PropTypeDefault
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxSeparator

Takes the attributes of its element.

ComboboxTrigger

PropTypeDefault
disabledWhether the component should ignore user interaction.booleanfalse
nativeButtonWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).booleantrue
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

ComboboxTriggerCount, ComboboxTriggerIndicator

Takes the attributes of its element.

ComboboxValue

PropTypeDefault
childrenAccepts a function that returns a `ReactNode` to format the selected value. Treat the value as read-only: in `multiple` mode it may be a shared frozen array when nothing is selected.ReactNode | ((selectedValue: any) => React.ReactNode)
placeholderThe placeholder value to display when no value is selected. This is overridden by `children` if specified, or by a null item's label in `items`.ReactNode

Changes

  • 0.106.2 · ChangedList popups shrink and scroll on their side before flipping; the side axis is the last resort ([Elevation › Popups](https://raft-design.botiverse.build/foundations/elevation/#popups), [DropdownMenu › Long menus](https://raft-design.botiverse.build/components/dropdown-menu/#long-menus), [Popover › A long popover](https://raft-design.botiverse.build/components/popover/#a-long-popover)): DropdownMenuContent, SelectContent, ComboboxContent, ComboboxSelect on a desktop and a PopoverContent with a PopoverBody stay on the side they open on and shrink to the room there, scrolling their list, as long as it holds five rows (--popup-list-min-height: 178px with a mouse, 188px on a touch screen). With less they flip to the other side, and they open beside the trigger only when neither side holds five rows.
  • 0.103.4 · FixedFrame insets (Popover, DropdownMenu, ContextMenu, Select, Combobox, ComboboxSelect, Tooltip, PreviewCard, CoachMark, NotificationCenter, MobileNavServerPopover, ToastPositioner, ComposerSuggestionList): --raft-frame-inset-start and --raft-frame-inset-end are the corners of the window's top band (--raft-frame-inset-top), not columns down its sides. A popup anchored under the band keeps its own padding from the window's edge; only one anchored in the band (a title-bar control, or a context menu opened in the bar) keeps 8px clear of a corner.
  • 0.103.3 · FixedFrame insets (useFrameInsets, frameCollisionBoundary): opening a positioned popup (Popover, DropdownMenu, Select, Combobox, ComboboxSelect, ContextMenu, Tooltip, PreviewCard, NotificationCenter, MobileNavServerPopover, ComposerSuggestionList) no longer stalls the main thread when --raft-frame-inset-* holds a calc() or env(titlebar-area-*) expression on an overlay title bar.
  • 0.10.0 · Breaking ChangesField frames (Input, Textarea, InputGroup, Select, Combobox, ComboboxSelect, Composer, option Card, SearchTrigger) are drawn at 1px in line-field instead of 1.5px, on the phone too.
  • 0.5.37 · FixedBrutal Combobox keeps its shadow when open, as Select does: the control lifts 1px with shadow-raft-md instead of dropping the shadow. In Brutal, SelectContent and ComboboxContent now default sideOffset to 8px (was 4px), so the open trigger's shadow stays clear of the popup instead of running into it. Elegant keeps 4px; an explicit sideOffset still wins.
  • 0.1.0 · AddedExtended Lightbox with thumbnail strip and related chrome parts; added ComboboxTriggerCount and ContextMenuPopup.