ARIA 1.1 Combobox with Grid Popup Example
The following example combobox implements the combobox design pattern using a grid for the suggested values popup.
In this example, users can specify the name of a fruit or vegetable by either typing a value in the box or choosing from the set of values presented in a grid popup. The popup becomes available after the textbox contains a character that matches the beginning of the name of one of the items in the set of value suggestions. Users may type any value in the textbox; this implementation does not limit input to values that are in the set of value suggestions.
The grid that presents suggested values has two columns. Each row of the grid represents one suggestion; column one contains the name of the fruit or vegetable and column two identifies whether it is a fruit or vegetable.
Similar examples include:
- Examples of ARIA 1.1 Combobox with Listbox Popup: Comboboxes that demonstrate the various forms of autocomplete behavior using a listbox popup and use the ARIA 1.1 implementation pattern.
- ARIA 1.0 Combobox with Both List and Inline Autocomplete: A combobox that demonstrates the autocomplete behavior known as
list with inline autocomplete
and uses the ARIA 1.0 implementation pattern. - ARIA 1.0 Combobox with List Autocomplete: A combobox that demonstrates the autocomplete behavior known as
list with manual selection
and uses the ARIA 1.0 implementation pattern. - ARIA 1.0 Combobox Without Autocomplete: A combo box that demonstrates the behavior associated with
aria-autocomplete=none
and uses the ARIA 1.0 implementation pattern.
Example
Keyboard Support
The example combobox on this page implements the following keyboard interface. Other variations and options for the keyboard interface are described in the Keyboard Interaction section of the combobox design pattern.
Textbox
Key | Function |
---|---|
Down Arrow | If the grid is displayed, moves focus to the first suggested value. |
Up Arrow | If the grid is displayed, moves focus to the last suggested value. |
Escape |
|
Standard single line text editing keys |
|
Grid Popup
NOTE: When visual focus is in the grid, DOM focus remains on the textbox and the value of aria-activedescendant
on the textbox is set to a value that refers to an element in the grid that is visually indicated as focused.
Where the following descriptions of keyboard commands mention focus, they are referring to the visual focus indicator.
For more information about this focus management technique, see
Using aria-activedescendant to Manage Focus.
Key | Function |
---|---|
Enter |
|
Escape |
|
Down Arrow |
|
Up Arrow |
|
Right Arrow |
|
Left Arrow |
|
Home | Moves focus to the textbox and places the editing cursor at the beginning of the field. |
End | Moves focus to the textbox and places the editing cursor at the end of the field. |
Printable Characters |
|
Role, Property, State, and Tabindex Attributes
The example comboboxes on this page implement the following ARIA roles, states, and properties. Information about other ways of applying ARIA roles, states, and properties is available in the Roles, States, and Properties section of the combobox design pattern.
Combobox Container
Role | Attribute | Element | Usage |
---|---|---|---|
combobox
|
div |
|
|
aria-haspopup=
|
div |
Indicates that the combobox can popup a grid to suggest values. |
|
aria-owns=
|
div |
|
|
aria-expanded=
|
div |
Indicates that the popup element is not displayed. | |
aria-expanded=
|
div |
Indicates that the popup element is displayed. |
Textbox
Role | Attribute | Element | Usage |
---|---|---|---|
id="string"
|
input[type="text"] |
|
|
aria-autocomplete=
|
input[type="text"] |
Indicates that the autocomplete behavior of the text input is to suggest a list of possible values in a popup. | |
aria-controls=
|
input[type="text"] |
|
|
aria-activedescendant=
|
input[type="text"] |
|
Grid Popup
Role | Attribute | Element | Usage |
---|---|---|---|
grid
|
div
|
Identifies the element as a grid . |
|
aria-labelledby=
|
div |
Provides a label for the grid element of the combobox. |
|
row
|
div |
Identifies the element containing all the cells for a row. | |
aria-selected=
|
div |
|
|
gridcell |
div |
Identifies the element containing the content for a single cell. |
Javascript and CSS Source Code
- CSS: combobox-1.1.css
- Javascript: grid-combobox.js
- Javascript: grid-combo-example.js
HTML Source Code