---
description: >-
  ComboBoxes combine a text input with a dropdown menu, allowing users to either
  select an option from the list or enter their own value. It is a versatile
  component that enhance user input flexibility.
---

# ComboBox

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2F10godPQEXV1P3f9cimU0%2FFrame%2045.png?alt=media&#x26;token=008b8cd6-7392-49b1-b5ab-0e7e9ddc1ce1" alt=""><figcaption></figcaption></figure>

## Overview

A combobox combines the flexibility of a text input with the simplicity of a dropdown, allowing users to either select from a pre-defined list or type their own value.

{% embed url="https://www.figma.com/design/4NwKhd4dwRhRF5Zpiooi69/Components?node-id=59-58633&t=0Thv0LIO2gFzE3eo-4" %}

## When to use

* Use a combobox when users need to select from a list of options but may also need the freedom to input their own custom value.&#x20;
* When a dropdown list contains many options, and searching within the list enhances usability, a combobox is an ideal solution.&#x20;
* Apply a combobox if the list of selectable options may change based on user input or contextual conditions, giving users flexibility to add new options.&#x20;
* In cases where you need to minimize space in forms, a combobox helps by combining a text field and dropdown into a single interactive component.

## When not to use

* If it’s essential that users compare all options before selecting, use a radio button or checkbox list, as comboboxes limit the number of visible options.&#x20;
* If the input requires extensive validation or complex formats, a combobox may not provide the necessary structure and could cause confusion.&#x20;
* If there are only a few options, a simple dropdown or radio buttons may be more efficient and clearer than a combobox.

## Anatomy

1. **Icon Leading:** An optional icon that appears at the start of the combobox input field, indicating the type of content.&#x20;
2. **Label:** Describes the field, guiding users on what to select or input.&#x20;
3. **Tag:** Representing selected items within the combobox field.&#x20;
4. **Input Field:** A text box where users can type to filter options or make a selection. It's the interactive area for text input.&#x20;
5. **Count:** Displays the number of items selected or available for selection.&#x20;
6. **Icon Trailing:** An icon (such as a dropdown arrow) located on the right side of the input field.&#x20;
7. **Menu Option:** The list of selectable items within the expanded menu. Users can scroll or type to search for options.

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2FMJ9jlBBXnIT72km8XOkp%2FAnatomy.png?alt=media&#x26;token=71aa915f-a0a5-4f0f-8427-e6eb3e2ce5ab" alt=""><figcaption></figcaption></figure>

## Styles

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2FTvqgdpPHueOtk0lcdMXZ%2FStyle.png?alt=media&#x26;token=6b48540c-7720-46cb-a6ed-9cd1bfb34658" alt=""><figcaption></figcaption></figure>

## States

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2FhVqDMIZVjNPOI8bRFJE1%2FState.png?alt=media&#x26;token=cb57b95e-f246-4ac4-b2f0-d971fb45b0e2" alt=""><figcaption></figcaption></figure>

## Size

<figure><img src="https://1456965416-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOHrijNlCiWxhWuZ7eBdg%2Fuploads%2FMJwqE9OXIJnV8GA8zcOo%2FSize.png?alt=media&#x26;token=54628017-ffab-4449-b300-56b8cc99c6d4" alt=""><figcaption></figcaption></figure>

<table><thead><tr><th width="152">Size</th><th width="123">Text (px)</th><th width="108">Icon (px)</th><th width="128">Corner (px)</th><th>Container Height (px)</th></tr></thead><tbody><tr><td>Small</td><td>14</td><td>20</td><td>8</td><td>32</td></tr><tr><td>Medium</td><td>14</td><td>20</td><td>8</td><td>42</td></tr><tr><td>Large</td><td>16</td><td>24</td><td>8</td><td>50</td></tr></tbody></table>

## Accessibility

* **Keyboard Navigation:** Ensure the combobox is fully accessible via keyboard. Users should be able to navigate through options using the arrow keys and select items with "Enter" or "Space."&#x20;
* **Clear Focus Indicators:** The focus state should be visibly distinct to assist users relying on keyboard navigation.&#x20;
* **Screen Readers:** Combobox components should clearly indicate when they are expanded or collapsed. Each option should be announced as users navigate through the list, and any custom value entered by the user should also be vocalized.

## Example

* **Country Selection in a Form:** A combobox allows users to either search for their country or type it directly, useful when handling extensive lists like countries or cities.&#x20;
* **Product Search in an E-commerce App:** Users can type in a product they’re looking for, and the combobox suggests matches from the store’s product catalog.&#x20;
* **Adding Participants to an Event:** A combobox allows users to select participants from a dropdown or input new participants’ emails if they’re not already in the system.&#x20;
* **Searchable Dropdown for Customer Feedback:** In a feedback form, users can either choose from common issues or type in a custom comment.
