Combobox

6 Combobox variations from the W3C ARIA Authoring Practices Guide.

Combobox (Date Picker)

An editable date combobox opens a modal calendar. A typed valid date determines initial calendar focus; invalid or empty text starts at today. The date format is explicitly described.

Corresponding W3C APG example

Example

Date format: mm/dd/yyyy

Choose a visit date

SuMoTuWeThFrSa

Use arrows to move by day or week. Home and End move within the week. Page Up and Page Down change month; add Shift to change year.

Keyboard interaction

Down or Alt+Down opens the calendar. Arrows move by day/week, Home/End to week boundaries, PageUp/PageDown by month, Shift+PageUp/PageDown by year. Space previews the date; Enter or OK commits. Escape or Cancel restores the original text and returns to the combobox.

Events

Listen on the widget or delegate to <axxy-scope> or document. All custom events bubble.

  • axxy-combobox-change — Dispatched when a combobox value or option is committed. (target: [role="combobox"], detail: { value: string, option: HTMLElement|null })
  • change — Standard change event dispatched on commit. (target: [role="combobox"], detail: Native Event)
  • axxy-datepicker-change — Dispatched when a date is chosen from the calendar. (target: <input>, detail: { value: string, date: Date })
  • input / change — Standard input and change events dispatched when the date updates. (target: <input>, detail: Native Event)

Events reference and examples

Example HTML

<axxy-scope>
  <div role="group" aria-label="Visit date picker" aria-roledescription="datepicker">
    <label for="combo-date">Visit date</label>
    <input id="combo-date" role="combobox" aria-describedby="combo-date-format" placeholder="mm/dd/yyyy" value="02/28/2024">
    <button type="button" aria-label="Choose date">Choose date</button>
    <p id="combo-date-format">Date format: mm/dd/yyyy</p>
    <dialog>
      <h3>Choose a visit date</h3>
      <div>
        <button type="button">Previous year</button>
        <button type="button">Previous month</button>
        <button type="button">Next month</button>
        <button type="button">Next year</button>
      </div>
      <h4></h4>
      <table aria-describedby="combo-date-help">
        <thead>
          <tr>
            <th scope="col" abbr="Sunday">Su</th>
            <th scope="col" abbr="Monday">Mo</th>
            <th scope="col" abbr="Tuesday">Tu</th>
            <th scope="col" abbr="Wednesday">We</th>
            <th scope="col" abbr="Thursday">Th</th>
            <th scope="col" abbr="Friday">Fr</th>
            <th scope="col" abbr="Saturday">Sa</th>
          </tr>
        </thead>
        <tbody></tbody>
      </table>
      <p id="combo-date-help">Use arrows to move by day or week. Home and End move within the week. Page Up and Page Down change month; add Shift to change year.</p>
      <button type="button">Cancel</button>
      <button type="button">OK</button>
    </dialog>
  </div>
</axxy-scope>

Combobox (Grid Popup)

An editable supply chooser presents each suggestion as a two-column row: material and studio department. Choosing either cell commits the material name.

Corresponding W3C APG example

Example

CanvasPainting
CardboardModel making
ChalkDrawing
ClaySculpture
CopperMetalwork
PaperDrawing

Keyboard interaction

Type to filter. Down/Up enters and moves between rows. Left/Right moves between cells, wrapping between rows. Enter commits the row. Home/End and typing return to ordinary text editing. Escape closes the grid.

Events

Listen on the widget or delegate to <axxy-scope> or document. All custom events bubble.

  • axxy-combobox-change — Dispatched when a combobox value or option is committed. (target: [role="combobox"], detail: { value: string, option: HTMLElement|null })
  • change — Standard change event dispatched on commit. (target: [role="combobox"], detail: Native Event)
  • axxy-grid-edit — Dispatched when entering or exiting interactive cell edit mode. (target: Cell (td / [role="gridcell"]), detail: { cell: HTMLElement, editing: boolean })

Events reference and examples

Example HTML

<axxy-scope>
  <label for="demo-stock">Studio stock</label>
  <input id="demo-stock" role="combobox" aria-autocomplete="list" autocomplete="off">
  <table role="grid" aria-label="Supply suggestions">
    <tbody>
      <tr>
        <td>Canvas</td>
        <td>Painting</td>
      </tr>
      <tr>
        <td>Cardboard</td>
        <td>Model making</td>
      </tr>
      <tr>
        <td>Chalk</td>
        <td>Drawing</td>
      </tr>
      <tr>
        <td>Clay</td>
        <td>Sculpture</td>
      </tr>
      <tr>
        <td>Copper</td>
        <td>Metalwork</td>
      </tr>
      <tr>
        <td>Paper</td>
        <td>Drawing</td>
      </tr>
    </tbody>
  </table>
</axxy-scope>

Combobox (List + Inline Autocomplete)

Supply suggestions complete the typed prefix inline. The untyped suffix is selected so you can continue typing or replace it. Leaving the field accepts the completion.

Corresponding W3C APG example

Example

  • Canvas
  • Cardboard
  • Chalk
  • Clay
  • Copper
  • Cotton
  • Ink
  • Paper
  • Pencil
  • Ribbon
  • Thread
  • Wood

Keyboard interaction

Type to edit. Down/Up explores suggestions while focus stays in the field. Enter chooses a suggestion. Escape closes the popup; a second Escape clears editable text. Tab leaves the field. The arrow button opens all choices.

Events

Listen on the widget or delegate to <axxy-scope> or document. All custom events bubble.

  • axxy-combobox-change — Dispatched when a combobox value or option is committed. (target: [role="combobox"], detail: { value: string, option: HTMLElement|null })
  • change — Standard change event dispatched on commit. (target: [role="combobox"], detail: Native Event)

Events reference and examples

Example HTML

<axxy-scope>
  <label for="demo-supply">Workshop supply</label>
  <div class="selection-field">
    <input id="demo-supply" role="combobox" aria-autocomplete="both" autocomplete="off">
    <button type="button" aria-label="Show supply choices">▾</button>
  </div>
  <ul role="listbox" style="max-height:12rem;overflow:auto;border:1px solid currentColor;padding:.5rem;list-style:none">
    <li>Canvas</li>
    <li>Cardboard</li>
    <li>Chalk</li>
    <li>Clay</li>
    <li>Copper</li>
    <li>Cotton</li>
    <li>Ink</li>
    <li>Paper</li>
    <li>Pencil</li>
    <li>Ribbon</li>
    <li>Thread</li>
    <li>Wood</li>
  </ul>
</axxy-scope>

Combobox (List Autocomplete)

Supply suggestions match the typed prefix. No suggestion is automatically chosen; leaving the field preserves your typed text.

Corresponding W3C APG example

Example

  • Canvas
  • Cardboard
  • Chalk
  • Clay
  • Copper
  • Cotton
  • Ink
  • Paper
  • Pencil
  • Ribbon
  • Thread
  • Wood

Keyboard interaction

Type to edit. Down/Up explores suggestions while focus stays in the field. Enter chooses a suggestion. Escape closes the popup; a second Escape clears editable text. Tab leaves the field. The arrow button opens all choices.

Events

Listen on the widget or delegate to <axxy-scope> or document. All custom events bubble.

  • axxy-combobox-change — Dispatched when a combobox value or option is committed. (target: [role="combobox"], detail: { value: string, option: HTMLElement|null })
  • change — Standard change event dispatched on commit. (target: [role="combobox"], detail: Native Event)

Events reference and examples

Example HTML

<axxy-scope>
  <label for="demo-supply">Workshop supply</label>
  <div class="selection-field">
    <input id="demo-supply" role="combobox" aria-autocomplete="list" autocomplete="off">
    <button type="button" aria-label="Show supply choices">▾</button>
  </div>
  <ul role="listbox" style="max-height:12rem;overflow:auto;border:1px solid currentColor;padding:.5rem;list-style:none">
    <li>Canvas</li>
    <li>Cardboard</li>
    <li>Chalk</li>
    <li>Clay</li>
    <li>Copper</li>
    <li>Cotton</li>
    <li>Ink</li>
    <li>Paper</li>
    <li>Pencil</li>
    <li>Ribbon</li>
    <li>Thread</li>
    <li>Wood</li>
  </ul>
</axxy-scope>

Combobox (No Autocomplete)

The popup always offers the complete supply list, regardless of what you type. Freeform text is allowed.

Corresponding W3C APG example

Example

  • Canvas
  • Cardboard
  • Chalk
  • Clay
  • Copper
  • Cotton
  • Ink
  • Paper
  • Pencil
  • Ribbon
  • Thread
  • Wood

Keyboard interaction

Type to edit. Down/Up explores suggestions while focus stays in the field. Enter chooses a suggestion. Escape closes the popup; a second Escape clears editable text. Tab leaves the field. The arrow button opens all choices.

Events

Listen on the widget or delegate to <axxy-scope> or document. All custom events bubble.

  • axxy-combobox-change — Dispatched when a combobox value or option is committed. (target: [role="combobox"], detail: { value: string, option: HTMLElement|null })
  • change — Standard change event dispatched on commit. (target: [role="combobox"], detail: Native Event)

Events reference and examples

Example HTML

<axxy-scope>
  <label for="demo-supply">Workshop supply</label>
  <div class="selection-field">
    <input id="demo-supply" role="combobox" aria-autocomplete="none" autocomplete="off">
    <button type="button" aria-label="Show supply choices">▾</button>
  </div>
  <ul role="listbox" style="max-height:12rem;overflow:auto;border:1px solid currentColor;padding:.5rem;list-style:none">
    <li>Canvas</li>
    <li>Cardboard</li>
    <li>Chalk</li>
    <li>Clay</li>
    <li>Copper</li>
    <li>Cotton</li>
    <li>Ink</li>
    <li>Paper</li>
    <li>Pencil</li>
    <li>Ribbon</li>
    <li>Thread</li>
    <li>Wood</li>
  </ul>
</axxy-scope>

Combobox (Select-Only)

Choose a workshop material without entering freeform text. Exploring options leaves the displayed value unchanged until you commit. Escape cancels the tentative choice.

Corresponding W3C APG example

Example

Workshop material
Canvas
  • Canvas
  • Cardboard
  • Chalk
  • Clay
  • Copper
  • Cotton
  • Ink
  • Paper
  • Pencil
  • Ribbon
  • Thread
  • Wood

Keyboard interaction

Enter, Space, or Down opens the popup. Arrows, Home/End, PageUp/PageDown, and typed letters explore choices. Enter, Space, Tab, or leaving the field commits. Escape or clicking the field again cancels.

Events

Listen on the widget or delegate to <axxy-scope> or document. All custom events bubble.

  • axxy-combobox-change — Dispatched when a combobox value or option is committed. (target: [role="combobox"], detail: { value: string, option: HTMLElement|null })
  • change — Standard change event dispatched on commit. (target: [role="combobox"], detail: Native Event)

Events reference and examples

Example HTML

<axxy-scope>
  <span id="demo-material-label">Workshop material</span>
  <div id="demo-material" role="combobox" aria-labelledby="demo-material-label" class="selection-field" style="border:1px solid currentColor;padding:.5rem">Canvas</div>
  <ul role="listbox" style="max-height:12rem;overflow:auto;border:1px solid currentColor;padding:.5rem;list-style:none">
    <li>Canvas</li>
    <li>Cardboard</li>
    <li>Chalk</li>
    <li>Clay</li>
    <li>Copper</li>
    <li>Cotton</li>
    <li>Ink</li>
    <li>Paper</li>
    <li>Pencil</li>
    <li>Ribbon</li>
    <li>Thread</li>
    <li>Wood</li>
  </ul>
</axxy-scope>