Back to Chromium

Component Spec: Comboboxes

agents/projects/chrome-design-system/assets/component-specs/Comboboxes_Spec.md

153.0.7995.13.4 KB
Original Source

Component Spec: Comboboxes

This specification document outlines the mapping, design tokens, styling variants, and interactive states of the Comboboxes component across Figma, C++ Views, and WebUI (Web Frontend).


Overview

Comboboxes allow users to select an option from a dropdown menu. They come in two primary flavors: a standard dropdown (select) and an editable combobox allowing users to type a custom value or filter choices.


1. Component Metadata & Source Files

FeatureFigma ComponentC++ Views (Desktop)WebUI (Web Frontend)
Component NameComboboxesviews::Combobox<select class="md-select">
Source FilesFigma Link: 280:26332ui/views/controls/combobox/combobox.hui/webui/resources/cr_elements/md_select_lit.css

2. Styling, Variants & Features (Layout & Style)

Figma VariantC++ ClassesWebUI Element/Class
Defaultviews::Combobox<select class="md-select">
Editable Comboboxviews::EditableComboboxCustom input/dropdown pairs

3. Component States

Interactive StateFigmaC++ views::ComboboxWebUI <select>
Defaultstate="Default"Normal drawingNormal layout
Hoveredstate="Hovered"InkDrop / Hover state:hover
Pressedstate="Pressed"IsMenuRunning()Active / Dropdown open
Disabledstate="Disabled"SetEnabled(false)[disabled] attribute

4. Design Token Comparison (Side-by-Side)

Token TypeFigma PropertyC++ ViewsWebUI Variable / CSS
Corner Radius8pxLayout Providerborder-radius: 8px / 4px
Padding10pxGetInsets()padding based on md-select
Border ColorNeutral Outlineui::kColorComboboxBackgroundborder-color
Disabled BackgroundState Disabled ContainerInherits from system--md-select-disabled-background

5. Architectural & Implementation Gaps

  • C++ Menu Integration: views::Combobox ties directly into ui::ComboboxModel and spins up a native menu (via views::MenuRunner). views::EditableCombobox is heavily specialized for text input combined with suggestions.
  • WebUI: A native <select> element styled with .md-select is most common, avoiding complex DOM/JS dropdowns unless rich contents (like icons per item) are needed, in which case <cr-action-menu> or custom components are used.

6. Styling, Variants, Features and States Mismatches

  • Arrow Customization: The dropdown arrow in WebUI is often customized using background SVG masks (e.g., images/select.png), while C++ draws it via vector icons.

7. Usage & UX Guidance

1. General Principles & Best Practices

  • When to use: Use when there are more than 4-5 options. For fewer options, consider radio buttons or segmented controls.

2. Platform Consistency, Keyboard Controls & Accessibility (a11y)

  • Keyboard: Standard up/down arrow navigation. C++ manages prefix selection delegates.

8. Inheritance Structure

  • C++ Views (Desktop): views::Viewviews::Combobox
  • WebUI (Web Frontend): Native HTMLSelectElement styled by md_select_lit.css