Combobox

Search and select one or more values from a customizable menu.

Requires JS
Layer: components
1 dependency

Chip input is now part of Combobox. Use editable Combobox for free-entry values and multiple selections as chips. See the migration guide to update existing chip inputs.

Overview

The combobox component provides a styled select experience using standard HTML markup. Pair an editable input or a toggle button with a .menu overlay. Combobox is markup-first: you write the control and menu items in HTML, and Bootstrap handles filtering, keyboard navigation, selection, and form submission.

  • Custom menu item content, including icons, descriptions, badges, and images
  • Live filtering as you type in the field or in a button’s menu search input
  • Optional check marks for selected items
  • Single and multiple selection, with removable chips for multiple values in the editable field
  • Optional free entry for values outside the menu
  • Keyboard navigation for suggestions, with shortcuts for selecting and removing chips
  • Form submission through generated or provided hidden inputs, with one entry per selected value in multiple mode
  • Bubbling input and change events when a selection changes

Example

Add data-bs-toggle="combobox" to a .combobox wrapper with a .combobox-input inside. Place a .menu after the wrapper, and give each selectable .menu-item a data-bs-value.

Type in the input to filter the options. The input keeps focus while the arrow keys highlight suggestions. Press Enter to commit a highlighted option. Typing alone does not select it.

HTML
<label class="form-label" for="editableLanguage">Language</label>
<div class="combobox" data-bs-toggle="combobox" data-bs-name="language">
  <input class="form-control combobox-input" id="editableLanguage" placeholder="Choose a language">
</div>
<div class="menu" aria-label="Languages">
  <button class="menu-item" type="button" data-bs-value="en">English</button>
  <button class="menu-item" type="button" data-bs-value="fr">French</button>
  <button class="menu-item" type="button" data-bs-value="ja">Japanese</button>
</div>

We set the input’s combobox attributes and the listbox option IDs. Give the input an accessible name with a label. Keep the query input unnamed; data-bs-name names the submitted backing fields. Editing a selected single value clears its committed value until you select an option again.

Placeholders

Use the input’s placeholder attribute to show a hint before you type or select a value.

HTML
<label class="form-label" for="comboboxCountry">Country</label>
<div class="combobox" data-bs-toggle="combobox" data-bs-name="country">
  <input class="form-control combobox-input" id="comboboxCountry" placeholder="Pick a country…">
</div>
<div class="menu">
  <button class="menu-item" type="button" data-bs-value="us">United States</button>
  <button class="menu-item" type="button" data-bs-value="uk">United Kingdom</button>
  <button class="menu-item" type="button" data-bs-value="ca">Canada</button>
</div>

Pre-selected value

Add .selected to a menu item to preselect it. The input shows that option’s label when Combobox initializes.

HTML
<label class="form-label" for="comboboxRole">Role</label>
<div class="combobox" data-bs-toggle="combobox" data-bs-name="role">
  <input class="form-control combobox-input" id="comboboxRole" placeholder="Choose a role…">
</div>
<div class="menu">
  <button class="menu-item" type="button" data-bs-value="admin">Admin</button>
  <button class="menu-item selected" type="button" data-bs-value="editor" aria-selected="true">Editor</button>
  <button class="menu-item" type="button" data-bs-value="viewer">Viewer</button>
</div>

With form field

Use the form field component to stack a label, Combobox, and any help text or validation messages.

HTML
<div class="form-field">
  <label for="exampleCombobox" class="form-label">Combobox</label>
  <div class="combobox" data-bs-toggle="combobox" data-bs-name="country">
    <input class="form-control combobox-input" id="exampleCombobox" placeholder="Pick a country…">
  </div>
  <div class="menu">
    <button class="menu-item" type="button" data-bs-value="us">United States</button>
    <button class="menu-item" type="button" data-bs-value="uk">United Kingdom</button>
    <button class="menu-item" type="button" data-bs-value="ca">Canada</button>
  </div>
</div>

Multiple selections as chips

Use .combobox-control for a wrapping field and add data-bs-multiple="true". The input uses .form-ghost to share the field with selected chips. Remove buttons include the option’s name. An empty multiple selection submits no entries.

HTML
<label for="editableInterests" class="form-label">Interests</label>
<div class="combobox-control" data-bs-toggle="combobox"
      data-bs-name="interests" data-bs-multiple="true">
  <input class="form-ghost combobox-input" id="editableInterests" placeholder="Add an interest">
</div>
<div class="menu" aria-label="Interests">
  <button class="menu-item" type="button" data-bs-value="design">Design</button>
  <button class="menu-item" type="button" data-bs-value="art,music">Art, music</button>
  <button class="menu-item" type="button" data-bs-value="engineering">Engineering</button>
</div>

Selecting an option clears the query and keeps the editor ready for another search. The chips use the existing chip styles. The menu remains the source of option identity and submitted values.

Free-entry values

Set data-bs-allow-custom="true" to accept values outside the option list. Press Enter to commit the text. A popup is optional for a field with no predefined options; we create one when needed. We render value labels as text.

HTML
<label for="editableTags" class="form-label">Tags</label>
<div class="combobox-control" data-bs-toggle="combobox"
      data-bs-name="tags" data-bs-multiple="true" data-bs-allow-custom="true">
  <input class="form-ghost combobox-input" id="editableTags" placeholder="Type a tag and press Enter">
</div>

Commas remain part of a value by default. Set separator explicitly to split typed or pasted values. createOnBlur is off by default so moving focus does not commit unfinished text. maxItems limits committed multiple selections. Repeated free-entry strings reuse an existing option rather than creating another chip.

Editor keyboard behavior

  • ↑ and ↓ highlight available suggestions while focus stays in the input.
  • Enter commits the active suggestion, or the query when free entry is enabled.
  • Escape closes the popup. Tab leaves the field without selecting a suggestion.
  • With an empty query, Backspace or Delete focuses and highlights the last enabled chip. Press either key on a chip to remove the highlighted chips.
  • Horizontal arrow keys move between chips in the field’s direction. Hold Shift to extend or shrink a range from its anchor. Home selects the first chip; Shift+End extends to the last. Plain End or Escape clears the chip highlight and returns to the editor.
  • Click a chip to highlight it. Use Ctrl or Cmd while clicking to toggle individual highlights, or Shift to select a range.
  • Ctrl+A or Cmd+A selects all enabled chips when a chip has focus or the query is empty. With query text, the input keeps native text selection.

Chip highlights use the filled .active style. Focusing a chip or tabbing to its remove button also highlights the chip. They select values for a removal action; they do not change submitted values. Returning to the input clears these highlights. Bulk removal emits one committed change and honors each option’s cancelable removal event.

Input-method composition takes precedence over component shortcuts. Removable chips also provide named buttons for direct keyboard access. Check the complete multiple-value interaction with your supported browsers and assistive technologies before release.

Custom content

Menu items can include icons, images, descriptions, and badges.

Icons

Add .menu-item-icon directly to an <svg> element inside a menu item for a leading icon.

HTML
<label class="form-label" for="comboboxIconLanguage">Language</label>
<div class="combobox" data-bs-toggle="combobox" data-bs-name="language">
  <input class="form-control combobox-input" id="comboboxIconLanguage" placeholder="Choose a language…">
</div>
<div class="menu">
  <button class="menu-item" type="button" data-bs-value="html">
    <svg class="menu-item-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5z"/></svg>
    <span>HTML</span>
  </button>
  <button class="menu-item" type="button" data-bs-value="css">
    <svg class="menu-item-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5z"/></svg>
    <span>CSS</span>
  </button>
  <button class="menu-item" type="button" data-bs-value="js">
    <svg class="menu-item-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M14 4.5V14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V2a2 2 0 0 1 2-2h5.5zm-3 0A1.5 1.5 0 0 1 9.5 3V1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1V4.5z"/></svg>
    <span>JavaScript</span>
  </button>
</div>

Descriptions

Use .menu-item-content for a flex column layout and .menu-item-description for secondary text.

HTML
<label class="form-label" for="comboboxRoleDetails">Role</label>
<div class="combobox" data-bs-toggle="combobox" data-bs-name="role">
  <input class="form-control combobox-input" id="comboboxRoleDetails" placeholder="Select a role…">
</div>
<div class="menu">
  <button class="menu-item" type="button" data-bs-value="admin">
    <span class="menu-item-content">
      <span>Admin</span>
      <small class="menu-item-description">Full access to all resources</small>
    </span>
  </button>
  <button class="menu-item" type="button" data-bs-value="editor">
    <span class="menu-item-content">
      <span>Editor</span>
      <small class="menu-item-description">Can edit and publish content</small>
    </span>
  </button>
  <button class="menu-item" type="button" data-bs-value="viewer">
    <span class="menu-item-content">
      <span>Viewer</span>
      <small class="menu-item-description">Read-only access</small>
    </span>
  </button>
</div>

Checked icon

Add .menu-item-check directly on an <svg> inside each menu item to show a check mark indicator. It is hidden by default and becomes visible when the item has the .selected class.

HTML
<label class="form-label" for="comboboxStatus">Status</label>
<div class="combobox" data-bs-toggle="combobox" data-bs-name="status">
  <input class="form-control combobox-input" id="comboboxStatus" placeholder="Choose a status…">
</div>
<div class="menu">
  <button class="menu-item selected" type="button" data-bs-value="active" aria-selected="true">
    <span class="menu-item-content">
      <span>Active</span>
      <small class="menu-item-description">Visible to users</small>
    </span>
    <svg class="menu-item-check" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 16 16"><path d="m2 7 4 5 8-8"/></svg>
  </button>
  <button class="menu-item" type="button" data-bs-value="draft">
    <span class="menu-item-content">
      <span>Draft</span>
      <small class="menu-item-description">Not yet published</small>
    </span>
    <svg class="menu-item-check" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 16 16"><path d="m2 7 4 5 8-8"/></svg>
  </button>
  <hr class="menu-divider">
  <button class="menu-item" type="button" data-bs-value="archived">
    <span>Archived</span>
    <svg class="menu-item-check" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 16 16"><path d="m2 7 4 5 8-8"/></svg>
  </button>
</div>

All together

Combine all three for a rich menu item layout.

HTML
<label class="form-label" for="comboboxPriority">Priority</label>
<div class="combobox" data-bs-toggle="combobox" data-bs-name="priority">
  <input class="form-control combobox-input" id="comboboxPriority" placeholder="Set priority…">
</div>
<div class="menu">
  <button class="menu-item" type="button" data-bs-value="low">
    <svg class="menu-item-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M8 15A7 7 0 1 1 8 1a7 7 0 0 1 0 14m0 1A8 8 0 1 0 8 0a8 8 0 0 0 0 16"/></svg>
    <span class="menu-item-content">
      <span>Low</span>
      <small class="menu-item-description">No rush</small>
    </span>
    <svg class="menu-item-check" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 16 16"><path d="m2 7 4 5 8-8"/></svg>
  </button>
  <button class="menu-item" type="button" data-bs-value="medium">
    <svg class="menu-item-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M6.79 5.093A.5.5 0 0 0 6 5.5v5a.5.5 0 0 0 .79.407l3.5-2.5a.5.5 0 0 0 0-.814z"/></svg>
    <span class="menu-item-content">
      <span>Medium</span>
      <small class="menu-item-description">Normal priority</small>
    </span>
    <svg class="menu-item-check" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 16 16"><path d="m2 7 4 5 8-8"/></svg>
  </button>
  <button class="menu-item" type="button" data-bs-value="high">
    <svg class="menu-item-icon" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M8 4a.905.905 0 0 0-.9.995l.35 3.507a.552.552 0 0 0 1.1 0l.35-3.507A.905.905 0 0 0 8 4m.002 6a1 1 0 1 0 0 2 1 1 0 0 0 0-2"/></svg>
    <span class="menu-item-content">
      <span>High</span>
      <small class="menu-item-description">Needs attention</small>
    </span>
    <svg class="menu-item-check" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 16 16"><path d="m2 7 4 5 8-8"/></svg>
  </button>
</div>

Groups

Use .menu-header elements to create labeled groups within the menu.

HTML
<label class="form-label" for="comboboxLanguageGroup">Language</label>
<div class="combobox" data-bs-toggle="combobox" data-bs-name="language">
  <input class="form-control combobox-input" id="comboboxLanguageGroup" placeholder="Select a language…">
</div>
<div class="menu">
  <div class="menu-header">Frontend</div>
  <button class="menu-item" type="button" data-bs-value="html">HTML</button>
  <button class="menu-item" type="button" data-bs-value="css">CSS</button>
  <button class="menu-item" type="button" data-bs-value="js">JavaScript</button>
  <div class="menu-header">Backend</div>
  <button class="menu-item" type="button" data-bs-value="python">Python</button>
  <button class="menu-item" type="button" data-bs-value="ruby">Ruby</button>
  <button class="menu-item" type="button" data-bs-value="go">Go</button>
</div>

Sizing

Use .form-control-sm or .form-control-lg on the input to change size.

Multiple-selection fields follow the shared --bs-btn-input-* sizing tokens. Chips use the height left after vertical padding and borders. Use --bs-combobox-control-chip-height for a custom chip height.

HTML
<label class="form-label" for="comboboxSmall">Small</label>
<div class="combobox" data-bs-toggle="combobox">
  <input class="form-control form-control-sm combobox-input" id="comboboxSmall" placeholder="Small select…">
</div>
<div class="menu">
  <button class="menu-item" type="button" data-bs-value="1">Option one</button>
  <button class="menu-item" type="button" data-bs-value="2">Option two</button>
</div>

<label class="form-label mt-3" for="comboboxDefault">Default</label>
<div class="combobox" data-bs-toggle="combobox">
  <input class="form-control combobox-input" id="comboboxDefault" placeholder="Default select…">
</div>
<div class="menu">
  <button class="menu-item" type="button" data-bs-value="1">Option one</button>
  <button class="menu-item" type="button" data-bs-value="2">Option two</button>
</div>

<label class="form-label mt-3" for="comboboxLarge">Large</label>
<div class="combobox" data-bs-toggle="combobox">
  <input class="form-control form-control-lg combobox-input" id="comboboxLarge" placeholder="Large select…">
</div>
<div class="menu">
  <button class="menu-item" type="button" data-bs-value="1">Option one</button>
  <button class="menu-item" type="button" data-bs-value="2">Option two</button>
</div>

Disabled

Add disabled to the input or individual menu items.

HTML
<label class="form-label" for="comboboxDisabled">Disabled field</label>
<div class="combobox" data-bs-toggle="combobox">
  <input class="form-control combobox-input" id="comboboxDisabled" placeholder="Cannot interact…" disabled>
</div>
<div class="menu">
  <button class="menu-item" type="button" data-bs-value="1">Option one</button>
  <button class="menu-item" type="button" data-bs-value="2">Option two</button>
</div>

<label class="form-label mt-3" for="comboboxDisabledOption">Disabled option</label>
<div class="combobox" data-bs-toggle="combobox">
  <input class="form-control combobox-input" id="comboboxDisabledOption" placeholder="Select an option…">
</div>
<div class="menu">
  <button class="menu-item" type="button" data-bs-value="1">Available</button>
  <button class="menu-item" type="button" data-bs-value="2" disabled>Unavailable</button>
  <button class="menu-item" type="button" data-bs-value="3">Available</button>
</div>

Button examples

Use a button when you want to choose from a menu without typing in the field.

Basic button

Add data-bs-toggle="combobox" to a <button> element, followed by a .menu with .menu-item buttons. Each selectable item needs a data-bs-value attribute. Set data-bs-placeholder to display a hint in .combobox-value before selection.

HTML
<button class="form-control combobox-toggle" type="button"
      data-bs-toggle="combobox"
      aria-haspopup="listbox" aria-expanded="false" aria-controls="comboboxButtonOptions"
      data-bs-name="option"
      data-bs-placeholder="Select an item…">
  <span class="combobox-value">Select an item…</span>
  <svg class="combobox-caret" width="10" height="16" viewBox="0 0 10 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.46967 5.46967C0.762563 5.17678 1.23744 5.17678 1.53033 5.46967L5 8.93934L8.46967 5.46967C8.76256 5.17678 9.23744 5.17678 9.53033 5.46967C9.82322 5.76256 9.82322 6.23744 9.53033 6.53033L5.53033 10.5303C5.23744 10.8232 4.76256 10.8232 4.46967 10.5303L0.46967 6.53033C0.176777 6.23744 0.176777 5.76256 0.46967 5.46967Z" fill="currentcolor"/></svg>
</button>
<div class="menu" id="comboboxButtonOptions" role="listbox" aria-label="Options">
  <button class="menu-item" type="button" data-bs-value="1" aria-selected="false" role="option">Option one</button>
  <button class="menu-item" type="button" data-bs-value="2" aria-selected="false" role="option">Option two</button>
  <button class="menu-item" type="button" data-bs-value="3" aria-selected="false" role="option">Option three</button>
</div>

Search menu items

Enable filtering with data-bs-search="true" on the toggle. Add a search input and optional no-results message inside the .menu, before the items. Items are filtered by matching their textContent against the query.

HTML
<button class="form-control combobox-toggle" type="button"
      data-bs-toggle="combobox"
      aria-expanded="false" aria-controls="comboboxButtonCountries"
      data-bs-name="country"
      data-bs-placeholder="Select a country…"
      data-bs-search="true">
  <span class="combobox-value">Select a country…</span>
  <svg class="combobox-caret" width="10" height="16" viewBox="0 0 10 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.46967 5.46967C0.762563 5.17678 1.23744 5.17678 1.53033 5.46967L5 8.93934L8.46967 5.46967C8.76256 5.17678 9.23744 5.17678 9.53033 5.46967C9.82322 5.76256 9.82322 6.23744 9.53033 6.53033L5.53033 10.5303C5.23744 10.8232 4.76256 10.8232 4.46967 10.5303L0.46967 6.53033C0.176777 6.23744 0.176777 5.76256 0.46967 5.46967Z" fill="currentcolor"/></svg>
</button>
<div class="menu" id="comboboxButtonCountries">
  <div class="combobox-search">
    <input type="search" class="form-control combobox-search-input" placeholder="Search…" autocomplete="off" aria-label="Search…">
  </div>
  <button class="menu-item" type="button" data-bs-value="us">United States</button>
  <button class="menu-item" type="button" data-bs-value="uk">United Kingdom</button>
  <button class="menu-item" type="button" data-bs-value="ca">Canada</button>
  <button class="menu-item" type="button" data-bs-value="au">Australia</button>
  <button class="menu-item" type="button" data-bs-value="de">Germany</button>
  <button class="menu-item" type="button" data-bs-value="fr">France</button>
  <button class="menu-item" type="button" data-bs-value="jp">Japan</button>
  <button class="menu-item" type="button" data-bs-value="br">Brazil</button>
  <button class="menu-item" type="button" data-bs-value="in">India</button>
  <button class="menu-item" type="button" data-bs-value="mx">Mexico</button>
  <div class="combobox-no-results d-none">No results found</div>
</div>

Multiple select

Add data-bs-multiple="true" to the toggle for multi-select behavior. Selected items are toggled on click and the menu stays open. The toggle displays the count when more than one item is selected.

HTML
<button class="form-control combobox-toggle" type="button"
      data-bs-toggle="combobox"
      aria-haspopup="listbox" aria-expanded="false" aria-controls="comboboxButtonLanguages"
      data-bs-name="skills"
      data-bs-placeholder="Select skills…"
      data-bs-multiple="true">
  <span class="combobox-value">Select skills…</span>
  <svg class="combobox-caret" width="10" height="16" viewBox="0 0 10 16" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.46967 5.46967C0.762563 5.17678 1.23744 5.17678 1.53033 5.46967L5 8.93934L8.46967 5.46967C8.76256 5.17678 9.23744 5.17678 9.53033 5.46967C9.82322 5.76256 9.82322 6.23744 9.53033 6.53033L5.53033 10.5303C5.23744 10.8232 4.76256 10.8232 4.46967 10.5303L0.46967 6.53033C0.176777 6.23744 0.176777 5.76256 0.46967 5.46967Z" fill="currentcolor"/></svg>
</button>
<div class="menu" id="comboboxButtonLanguages" role="listbox" aria-label="Languages" aria-multiselectable="true">
  <button class="menu-item" type="button" data-bs-value="html" aria-selected="false" role="option">
    HTML
    <svg class="menu-item-check" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 16 16"><path d="m2 7 4 5 8-8"/></svg>
  </button>
  <button class="menu-item" type="button" data-bs-value="css" aria-selected="false" role="option">
    CSS
    <svg class="menu-item-check" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 16 16"><path d="m2 7 4 5 8-8"/></svg>
  </button>
  <button class="menu-item" type="button" data-bs-value="js" aria-selected="false" role="option">
    JavaScript
    <svg class="menu-item-check" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 16 16"><path d="m2 7 4 5 8-8"/></svg>
  </button>
  <button class="menu-item" type="button" data-bs-value="python" aria-selected="false" role="option">
    Python
    <svg class="menu-item-check" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 16 16"><path d="m2 7 4 5 8-8"/></svg>
  </button>
  <button class="menu-item" type="button" data-bs-value="ruby" aria-selected="false" role="option">
    Ruby
    <svg class="menu-item-check" xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" viewBox="0 0 16 16"><path d="m2 7 4 5 8-8"/></svg>
  </button>
</div>

Form submission

The combobox creates a hidden <input> for form submission when data-bs-name is set on the wrapper or button. The hidden input’s name matches the attribute value and its value updates whenever the selection changes.

HTML
<!-- What you write -->
<label for="countryPickerInput">Country</label>
<div id="countryPicker" class="combobox" data-bs-toggle="combobox" data-bs-name="country">
  <input class="form-control combobox-input" id="countryPickerInput">
</div>
<div class="menu">...</div>

<!-- What the JS creates (inserted before the wrapper) -->
<input type="hidden" name="country" value="us">

For multiple selection, each selected option submits a separate field with the same name. For example, selecting us and ca submits countries=us&countries=ca. Values that contain commas remain unchanged. If your server requires brackets, use data-bs-name="countries[]"; we copy the name as written.

The first hidden input remains in the DOM so event listeners keep a stable target. It holds the first submitted value. Additional inputs hold the remaining values in menu order. With no multiple selection, the first input is disabled and no values are submitted. Single selection keeps one field, empty when no option is selected.

JavaScript
const form = document.querySelector('#preferences')
const selectedCountries = new FormData(form).getAll('countries')

Use an existing input

Set data-bs-input to the selector of a hidden input, or pass the element as the input option. We use that field’s name and form owner. The name option applies only to automatically created fields.

HTML
<input type="hidden" id="comboboxCountryValue" name="country">
<label for="comboboxBoundCountry">Country</label>
<div class="combobox" data-bs-toggle="combobox" data-bs-input="#comboboxCountryValue">
  <input class="form-control combobox-input" id="comboboxBoundCountry">
</div>
<div class="menu" aria-label="Countries">
  <button class="menu-item selected" type="button" data-bs-value="us" role="option" aria-selected="true">United States</button>
  <button class="menu-item" type="button" data-bs-value="ca" role="option" aria-selected="false">Canada</button>
</div>

Mark the initial selection with .selected on the options. We sync the field from that markup; an existing field value does not select an option. Use an explicit selector for each component, even when several rows use the same field name. We do not infer a binding from neighboring elements or shared names.

Calling dispose() keeps a provided input, its current first value, and its application attributes. It removes generated inputs and component listeners. In multiple mode, generated fields for the other values are also removed. One provided input cannot preserve the entire repeated-value payload after disposal.

Disabled state, reset, and updates

A disabled input or button does not submit its generated fields. Provided inputs keep their own disabled setting. Generated fields follow the input or button’s form attribute, including forms outside the component’s parent.

Resetting the form restores the initial option selection, label, and submitted values. Preventing the form’s reset event cancels that change. Initialization, reset, and update() do not emit selection-change events.

We observe disabled and form-attribute changes. Call update() when you move the component or change its selected option markup. Also call it before reading FormData or submitting to a new form in the same task as an attribute change:

JavaScript
const picker = document.querySelector('#countryPicker')
const input = picker.querySelector('input')
const combobox = bootstrap.Combobox.getInstance(picker)

input.disabled = true
combobox.update()
const data = new FormData(input.form)

Normal form submission also synchronizes the fields before submission. If you replace the entire menu element, dispose the component and initialize it again. Applications own asynchronous option loading.

Hidden inputs do not participate in native constraint validation. Preserving attributes for an application validator does not add native required or pattern validation.

JavaScript

Via data attributes

AttributeDescription
data-bs-toggle="combobox"Initializes Combobox on the editable wrapper or button.
data-bs-valueOn a .menu-item, the value submitted and shown when that option is selected.
data-bs-searchEnables a search field inside the menu for a button Combobox.
data-bs-multipleEnables multi-select behavior.
data-bs-namename of the automatically created fields for form submission.
data-bs-inputSelector of a provided hidden input to reuse.
data-bs-placeholderPlaceholder text shown in the toggle when nothing is selected.

Dependencies

The combobox plugin requires the following JavaScript files if you’re building Bootstrap’s JS from source:

File Description
js/src/combobox.ts Main combobox component
js/src/base-component.ts Base component class
js/src/menu.ts Menu component
js/src/dom/data.ts Element data store
js/src/dom/event-handler.ts Event handling utilities
js/src/dom/manipulator.ts Data attribute manipulation
js/src/dom/selector-engine.ts DOM selector utilities
js/src/util/component-functions.ts Shared component helpers
js/src/util/config.ts Configuration base class
js/src/util/floating-ui.ts Responsive placement utilities
js/src/util/index.ts Core utility functions
@floating-ui/dom Third-party positioning library

Options

Options can be passed via data attributes on the wrapper or button (e.g., data-bs-search="true") or as a config object when initializing via JavaScript.

NameTypeDefaultDescription
allowCustombooleanfalseAllow free-entry values from the editable input.
createOnBlurbooleanfalseCommit free-entry text when the editor loses focus.
maxItemsnumber | nullnullPositive maximum number of committed multiple selections.
separatorstring | nullnullExplicit delimiter for typed or pasted free-entry values.
multiplebooleanfalseEnable multi-select mode. Selections toggle and the menu stays open.
namestring | nullnullName for automatically created fields. Also settable via data-bs-name.
inputstring | element | nullnullSelector or element for a provided hidden input. Its name and form owner are retained.
placeholderstring''Placeholder text for the button. Also settable via data-bs-placeholder.
searchbooleanfalseEnable search input in a button’s menu. Also settable via data-bs-search.
searchNormalizebooleanfalseNormalize accented characters for search matching.
placementstring'bottom-start'Menu placement (uses Floating UI).
offsetarray[0, 2]Offset from the toggle [skidding, distance].
boundarystring | element'clippingParents'Overflow boundary for the menu.

Methods

MethodDescription
getValuesReturns the committed values in menu order.
getSelectedValuesReturns the values of highlighted chips, without changing committed selections.
selectChip(chip, options)Highlights an owned chip. Use addToSelection for a toggle or rangeSelect to extend from the anchor.
clearSelectionClears chip highlights without removing values.
removeSelectedRemoves highlighted chips in one change, then focuses the nearest remaining chip or editor. Returns whether values changed.
add(value)Selects an existing value, or creates one when allowed. Returns its chip or option, or null.
remove(valueOrElement)Removes a selected value, option, or chip. Returns whether it changed.
clearRemoves enabled selections in one change.
focusFocuses the toggle or editable input.
toggleToggles the menu.
showShows the menu.
hideHides the menu.
disposeDestroys the combobox and its Menu instance, removes generated fields, and keeps a provided input.
updateSyncs the selected markup, label, and form attributes without firing change events.
getInstanceStatic method to get the combobox instance from a DOM element.
getOrCreateInstanceStatic method to get or create a combobox instance.

Menu controls the show and hide transitions. Combobox forwards its lifecycle events, including outside-click dismissal. Cancel show.bs.combobox or hide.bs.combobox to prevent that action. Await show() or hide() for transition completion.

Combobox owns the Menu instance registered on its input or button. Let Combobox create and dispose that instance. Do not replace or dispose the Menu separately.

Events

Component events fire on the component root: the wrapper for an editable field, or the button. Query input events remain native input events; they do not commit a value. When selection changes, we first update the label and all submitted fields. We then dispatch bubbling input and change events from the stable hidden input, followed by change.bs.combobox on the root. Without a backing field, the plain events also fire on the root.

Selecting the same single option again does not emit a change. Selecting a different option with the same value does. Read all multiple values from event.value on the component event or FormData.getAll(name), rather than the first hidden input’s value.

EventDescription
add.bs.comboboxFires before an option is selected. Cancel it to prevent selection. Has value and item properties.
remove.bs.comboboxFires before a selected option is removed. Cancel it to keep that value. Has value and item properties.
show.bs.comboboxFires immediately when the show method is called.
shown.bs.comboboxFires when the menu has been made visible.
hide.bs.comboboxFires immediately when the hide method is called.
hidden.bs.comboboxFires when the menu has been hidden.
select.bs.comboboxFires after chip highlights change. Contains selected values and their option items. Does not change form values.
change.bs.comboboxFires after selection changes. The event has value and item properties. value is an array in multiple mode.

Accessibility

Give the input a visible label. We set its role="combobox", connect it to the listbox, and update aria-expanded as the menu opens and closes. The input retains focus while you navigate suggestions with the arrow keys.

For a button that opens a listbox, give the button aria-haspopup="listbox" and aria-expanded="false". Set role="listbox" on the menu and use role="option" and aria-selected on its options. Use disabled on unavailable option buttons.

CSS custom properties

The combobox uses CSS custom properties prefixed with --combobox-* for the toggle, and inherits --menu-* properties from the Menu component for the menu overlay. See the source SCSS for the full list of available tokens.

Editable field variables

// stylelint-disable-next-line scss/dollar-variable-default
$combobox-control-tokens: defaults(
  (
    --combobox-control-padding-y: var(--btn-input-padding-y),
    --combobox-control-padding-x: var(--btn-input-padding-x),
    --combobox-control-gap: .25rem,
    --combobox-control-chip-height: calc(var(--control-min-height) - 2 * var(--combobox-control-padding-y) - 2 * var(--control-border-width)),
    --control-min-height: var(--btn-input-min-height),
    --control-font-size: var(--btn-input-font-size),
    --control-line-height: var(--btn-input-line-height),
    --combobox-control-ghost-min-width: 5rem,
    --control-fg: var(--btn-input-fg),
    --control-bg: var(--btn-input-bg),
    --control-border-width: var(--border-width),
    --control-border-color: var(--border-color),
    --control-border-radius: var(--radius-5),
  ),
  $combobox-control-tokens
);