Skip to content
me2 Accessibility logo Homepage

Accessible control for selecting multiple options

Provide screen reader access to complex control

You are here:

Auto-suggest Control

An Auto-suggest, multi-select control consists of an input field, a list of matching options below the input field, and a list of selected values above the input field. As the user types in the input field, the options below change accordingly.

This functionality can be clear for sighted users; however, it is often inaccessible to screen reader users because the users do not know that the control is a multi-select control and because the users cannot access the options.

The example control below is fully accessible and works for keyboard and screen reader use - try it by typing in the input field.

Demo: auto-suggest, multi-select control

Town

Notes

The ARIA specification does not define a full widget with this functionality and therefore the control must be "homemade". The demo provided above consists of three parts:

  • A standard input field that provides an explanation of the functionality via the label ("Town - type text, then select from options below. Selected values are displayed in list above. Type space to display all options.").
  • A list of checkboxes (the options) below the input field.
  • A list of values and "Remove" buttons (the selected values) above the input field.

The list and checkbox markup is implemented via ARIA roles; however, standard input, ul and li elements could be used instead.

To ensure screen reader access, the options do not close when the input field loses focus, instead, the options only close when the:

  • Close button is pressed, or
  • Escape key is pressed, or
  • Page is clicked outside the control.

In addition, the options are inserted in the DOM immediately after the input field. This enables screen reader users to easily access the options and to interact directly with the elements.

Code example

The code below shows the markup with one selected value displayed above the input field and two options available below the input field.

<div class="asms">
    <svg style="width: 300px; height: 74px; top: 0px; left: 0px;">
        <path d="M1,6 c0,-5 0,-5 5,-5 L230,1 c5,0 5,0 5,5 L235,28 c0,5 0,5 5,5 L284,33 c5,0 5,0 5,5 L289,58 c0,5 0,5 -5,5 L6,63 c-5,0 -5,0 -5,-5Z"/>
    </svg>
    <div role="list" class="selected">
        <div role="listitem">
            Aberfeldy Township
            <button type="button" aria-label="Remove Aberfeldy Township"></button>
        </div>
    </div>
    <input type="text" autocomplete="off" aria-label="Town - type text, then select from options below. Selected values are displayed in list above. Type space to display all options.">
    <span aria-live="assertive">
        2 options
    </span>
    <button aria-label="Close options" style="top: 66px; left: 286px;"></button>
    <div role="list" class="options" style="top: 65px; left: -2px;">
        <div role="listitem">
            <button role="checkbox" aria-checked="true">
                <span role="text">
                    Aberfeldy
                    <b>
                        Town
                    </b>
                    ship
                </span>
            </button>
        </div>
        <div role="listitem">
            <button role="checkbox" aria-checked="false">
                <span role="text">
                    Williams
                    <b>
                        town
                    </b>
                </span>
            </button>
        </div>
    </div>
</div>

Terms of Use

This software is being provided "as is" - without any express or implied warranty. In particular, me2 Accessibility does not make any representation or warranty of any kind concerning the reliability, quality, or merchantability of this software or its fitness for any particular purpose. In addition, me2 Accessibility does not guarantee that use of this tool will ensure the accessibility of your web content or that your web content will comply with any specific accessibility standard.

Creative commons licence - logo
This work is licensed under a Creative Commons License

Contact Us

Need a quote / Have a query?

Please get in touch

Contact Us
Level AA conformance, W3C WAI Web Content Accessibility Guidelines 2.2 Certified WCAG level AA. me2Accessibility logo