Creating an Accessible button dropdown

Russ Weakley
Russ WeakleyUX/UI developer at Max Design
Accessible

Button

Dropdown
Creating an
Introduction
My main role in recent times is to
work on the UX/UI and front-end
development of Pattern Libraries
for web applications.
However, I also work in the
Accessibility space. My focus in this
area is helping developers build
accessible web components for
complex Web apps.
One web component that can
present accessibility issues is the
button dropdown.
A button dropdown is where a
button is used to trigger the display
of contextual menus - such as a list
of links.
A diagram showing a button “Weyland Industries” with no dropdown displayed
A diagram showing a button “Weyland Industries” with the dropdown displayed below. 

The dropdown displays three options: “Weyland Industries”, “Stark Industries” and “Cyberdyne Systems”
We’re going to look at a range of
possible checkpoints that could
help make button dropdowns more
accessible.
We’ll use an imaginary example of a
button dropdown that allows users
to switch their current
organisation.
A diagram showing a button “Weyland Industries” with the dropdown displayed below. 

The dropdown displays three options: “Weyland Industries”, “Stark Industries” and “Cyberdyne Systems”
1.
Semantics
As the name suggests, the ideal
element that should be used for the
trigger, is the <button> element.
<button  type="button">  
    Weyland  Industries  
</button>
The fundamental difference between
buttons and links is that buttons
should do something (cause
something to happen), and links
should go somewhere (go to a
different location).
The markup for the dropdown
depends on the role of the items
inside. If the items are a list of links,
then an unordered list of links is
ideal.
<ul>  
    <li><a  href="#">Weyland  Industries</a></li>  
    <li><a  href="#">Stark  Industries</a></li>  
    <li><a  href="#">Cyberdyne  Systems</a></li>  
</ul>
2.
Getting to the button
Keyboard-only users should be
able to TAB to the button, which
then receives focus.
3.
Announcing the button
The aria-­‐label attribute can be
used to announce the button value
along with any additional
information to screen reader users.
For modern screen readers, the
aria-­‐label value will be
announced instead of the button
value.
<button  
    type="button"  
aria-­‐label="Current  company:  Weyland  Industries.  Use  
the  dropdown  menu  to  switch  companies"  
>  
    Weyland  Industries  
</button>
The aria-­‐haspopup="true"
attribute can be used to announce
the button as a “popup button” to
screen readers.
This is important, as it tells screen
reader users that it is a different
type of button - not a normal
button associated with submitting a
form etc.
<button  
    type="button"  
aria-­‐label="Current  company:  Weyland  Industries.  Use  
the  dropdown  menu  to  switch  companies"  
    aria-­‐haspopup="true"  
>  
    Weyland  Industries  
</button>
The aria-­‐expanded="false"
attribute can be used to announce
the current state of the popup
button to screen readers - i.e the
dropdown below the button is not
currently expanded.
The "false" value would need to
be changed to "true" via
JavaScript as soon as the user
triggers the button.
<button  
    type="button"  
aria-­‐label="Current  company:  Weyland  Industries.  Use  
the  dropdown  menu  to  switch  companies"  
    aria-­‐haspopup="true"  
    aria-­‐expanded="false"  
>  
    Weyland  Industries  
</button>
Alternatively, the aria-­‐
expanded="true" attribute could
be injected via JavaScript only
when the button is triggered -
which would reduce the amount of
information being announced.
4.
Triggering the button
For keyboard-only users, ENTER or
SPACEBAR strokes should trigger
the dropdown to appear.
5.
After the button is
triggered
If the aria-­‐expanded="false"
attribute is present in the default
button state, it should be changed
to aria-­‐expanded="true" via
JavaScript.
If the aria-­‐expanded="false"
attribute is not present in the
default button state, the aria-­‐
expanded="true" should be
injected via JavaScript.
<button  
    type="button"  
aria-­‐label="Current  company:  Weyland  Industries.  Use  
the  dropdown  menu  to  switch  companies"  
    aria-­‐haspopup="true"  
    aria-­‐expanded="true"  
>  
    Weyland  Industries  
</button>
Focus should immediately shift to
the <ul> element and the dropdown
should become visible.
This is something that most button
dropdown solutions do not solve
elegantly. In many cases, users
trigger the button but the focus
does not shift at all.
Users are either given silence after
they trigger the button, or the button
information is repeated again. This
can cause confusion for users who
cannot see that the dropdown has
been triggered, but nothing has
been announced.
The <ul> element could be given an
aria-­‐label value, which means
that when it receives focus, it’s
purpose is announced.
<ul  aria-­‐label="Switch  Companies">  
    <li><a  href="#">Weyland  Industries</a></li>  
    <li><a  href="#">Stark  Industries</a></li>  
    <li><a  href="#">Cyberdyne  Systems</a></li>  
</ul>  
A side note:

If the current organisation exists in
the long list of dropdown items, it
may be a good ideal to flag this item
as the current organisation for
screen reader users.
This can be achieved with a range
of different methods, including
providing additional information
that is hidden off-screen.
<ul  aria-­‐label="Switch  Companies">  
    <li>  
        <a  href="#">  
            <span  class="hidden">Current  company:  </span>  
            Weyland  Industries  
        </a>  
    </li>  
    <li><a  href="#">Stark  Industries</a></li>  
    <li><a  href="#">Cyberdyne  Systems</a></li>  
</ul>
8.
To escape the dropdown
For keyboard-only users, the ESC
keystroke should close the
dropdown and return focus to the
button.
7.
To navigate through
items within the
dropdown
When focus has shifted to the <ul>
element, keyboard-only users
should be able to use TAB, SHIFT
TAB, UP ARROW or DOWN
ARROW to move forwards or
backwards through the list items.
When users reach the start or end of
the list, UP ARROW and DOWN
ARROW keystrokes should then
have not have any effect.
8.
Selecting a dropdown
item
Keyboard-only users should be able
to select a dropdown menu item
using ENTER and possibly the
SPACEBAR keystrokes.
9.
To leave the dropdown
Keyboard-only users should be able
to TAB forward through the
dropdown items and then on to
other focusable items outside the
dropdown.
As soon focus leave the last
dropdown item, the dropdown
should disappear.
Users should be able to SHIFT
TAB backwards through the
dropdown items and back to the
button.
The dropdown should remain open
when the button receives focus.
(Users can close the dropdown by
triggering the button again).
Conclusion
So, that’s it. A few simple pointers
to help make button dropdowns
more accessible.

Thanks for listening!
Russ Weakley
Max Design
Site: maxdesign.com.au
Twitter: twitter.com/russmaxdesign
Slideshare: slideshare.net/maxdesign
Linkedin: linkedin.com/in/russweakley
1 of 59

More Related Content

What's hot(20)

Similar to Creating an Accessible button dropdown

2  front panel2  front panel
2 front panelAnkush Jamthikar
184 views6 slides

Similar to Creating an Accessible button dropdown(20)

Accessible modal windowsAccessible modal windows
Accessible modal windows
Russ Weakley9.3K views
2  front panel2  front panel
2 front panel
Ankush Jamthikar184 views
Ccure 9000 Admin user's manualCcure 9000 Admin user's manual
Ccure 9000 Admin user's manual
Bill Kelly33.5K views
Building Accessible Web ComponentsBuilding Accessible Web Components
Building Accessible Web Components
Russ Weakley1.9K views
NetsupportNetsupport
Netsupport
vpcamor632 views
Sap - Initiation ManualSap - Initiation Manual
Sap - Initiation Manual
Kumar M.152 views
Accessible code-patternsAccessible code-patterns
Accessible code-patterns
Francesco Bedussi65 views
(Manual spss)(Manual spss)
(Manual spss)
Enas Ahmed3.2K views
Getting started with workflowGetting started with workflow
Getting started with workflow
seenu126342 views

More from Russ Weakley(20)

Recently uploaded(20)

discussion post.pdfdiscussion post.pdf
discussion post.pdf
jessemercerail70 views
Dance KS5 BreakdownDance KS5 Breakdown
Dance KS5 Breakdown
WestHatch52 views
ICS3211_lecture 08_2023.pdfICS3211_lecture 08_2023.pdf
ICS3211_lecture 08_2023.pdf
Vanessa Camilleri68 views
Lecture: Open InnovationLecture: Open Innovation
Lecture: Open Innovation
Michal Hron82 views
Psychology KS4Psychology KS4
Psychology KS4
WestHatch52 views
Streaming Quiz 2023.pdfStreaming Quiz 2023.pdf
Streaming Quiz 2023.pdf
Quiz Club NITW87 views
Psychology KS5Psychology KS5
Psychology KS5
WestHatch53 views
Universe revised.pdfUniverse revised.pdf
Universe revised.pdf
DrHafizKosar84 views
Azure DevOps Pipeline setup for Mule APIs #36Azure DevOps Pipeline setup for Mule APIs #36
Azure DevOps Pipeline setup for Mule APIs #36
MysoreMuleSoftMeetup75 views
Chemistry of sex hormones.pptxChemistry of sex hormones.pptx
Chemistry of sex hormones.pptx
RAJ K. MAURYA97 views
Scope of Biochemistry.pptxScope of Biochemistry.pptx
Scope of Biochemistry.pptx
shoba shoba110 views
SIMPLE PRESENT TENSE_new.pptxSIMPLE PRESENT TENSE_new.pptx
SIMPLE PRESENT TENSE_new.pptx
nisrinamadani2146 views
Material del tarjetero LEES Travesías.docxMaterial del tarjetero LEES Travesías.docx
Material del tarjetero LEES Travesías.docx
Norberto Millán Muñoz57 views

Creating an Accessible button dropdown

  • 3. My main role in recent times is to work on the UX/UI and front-end development of Pattern Libraries for web applications.
  • 4. However, I also work in the Accessibility space. My focus in this area is helping developers build accessible web components for complex Web apps.
  • 5. One web component that can present accessibility issues is the button dropdown.
  • 6. A button dropdown is where a button is used to trigger the display of contextual menus - such as a list of links.
  • 7. A diagram showing a button “Weyland Industries” with no dropdown displayed
  • 8. A diagram showing a button “Weyland Industries” with the dropdown displayed below. The dropdown displays three options: “Weyland Industries”, “Stark Industries” and “Cyberdyne Systems”
  • 9. We’re going to look at a range of possible checkpoints that could help make button dropdowns more accessible.
  • 10. We’ll use an imaginary example of a button dropdown that allows users to switch their current organisation.
  • 11. A diagram showing a button “Weyland Industries” with the dropdown displayed below. The dropdown displays three options: “Weyland Industries”, “Stark Industries” and “Cyberdyne Systems”
  • 13. As the name suggests, the ideal element that should be used for the trigger, is the <button> element.
  • 14. <button  type="button">      Weyland  Industries   </button>
  • 15. The fundamental difference between buttons and links is that buttons should do something (cause something to happen), and links should go somewhere (go to a different location).
  • 16. The markup for the dropdown depends on the role of the items inside. If the items are a list of links, then an unordered list of links is ideal.
  • 17. <ul>      <li><a  href="#">Weyland  Industries</a></li>      <li><a  href="#">Stark  Industries</a></li>      <li><a  href="#">Cyberdyne  Systems</a></li>   </ul>
  • 19. Keyboard-only users should be able to TAB to the button, which then receives focus.
  • 21. The aria-­‐label attribute can be used to announce the button value along with any additional information to screen reader users.
  • 22. For modern screen readers, the aria-­‐label value will be announced instead of the button value.
  • 23. <button      type="button"   aria-­‐label="Current  company:  Weyland  Industries.  Use   the  dropdown  menu  to  switch  companies"   >      Weyland  Industries   </button>
  • 24. The aria-­‐haspopup="true" attribute can be used to announce the button as a “popup button” to screen readers.
  • 25. This is important, as it tells screen reader users that it is a different type of button - not a normal button associated with submitting a form etc.
  • 26. <button      type="button"   aria-­‐label="Current  company:  Weyland  Industries.  Use   the  dropdown  menu  to  switch  companies"      aria-­‐haspopup="true"   >      Weyland  Industries   </button>
  • 27. The aria-­‐expanded="false" attribute can be used to announce the current state of the popup button to screen readers - i.e the dropdown below the button is not currently expanded.
  • 28. The "false" value would need to be changed to "true" via JavaScript as soon as the user triggers the button.
  • 29. <button      type="button"   aria-­‐label="Current  company:  Weyland  Industries.  Use   the  dropdown  menu  to  switch  companies"      aria-­‐haspopup="true"      aria-­‐expanded="false"   >      Weyland  Industries   </button>
  • 30. Alternatively, the aria-­‐ expanded="true" attribute could be injected via JavaScript only when the button is triggered - which would reduce the amount of information being announced.
  • 32. For keyboard-only users, ENTER or SPACEBAR strokes should trigger the dropdown to appear.
  • 33. 5. After the button is triggered
  • 34. If the aria-­‐expanded="false" attribute is present in the default button state, it should be changed to aria-­‐expanded="true" via JavaScript.
  • 35. If the aria-­‐expanded="false" attribute is not present in the default button state, the aria-­‐ expanded="true" should be injected via JavaScript.
  • 36. <button      type="button"   aria-­‐label="Current  company:  Weyland  Industries.  Use   the  dropdown  menu  to  switch  companies"      aria-­‐haspopup="true"      aria-­‐expanded="true"   >      Weyland  Industries   </button>
  • 37. Focus should immediately shift to the <ul> element and the dropdown should become visible.
  • 38. This is something that most button dropdown solutions do not solve elegantly. In many cases, users trigger the button but the focus does not shift at all.
  • 39. Users are either given silence after they trigger the button, or the button information is repeated again. This can cause confusion for users who cannot see that the dropdown has been triggered, but nothing has been announced.
  • 40. The <ul> element could be given an aria-­‐label value, which means that when it receives focus, it’s purpose is announced.
  • 41. <ul  aria-­‐label="Switch  Companies">      <li><a  href="#">Weyland  Industries</a></li>      <li><a  href="#">Stark  Industries</a></li>      <li><a  href="#">Cyberdyne  Systems</a></li>   </ul>  
  • 42. A side note:
 If the current organisation exists in the long list of dropdown items, it may be a good ideal to flag this item as the current organisation for screen reader users.
  • 43. This can be achieved with a range of different methods, including providing additional information that is hidden off-screen.
  • 44. <ul  aria-­‐label="Switch  Companies">      <li>          <a  href="#">              <span  class="hidden">Current  company:  </span>              Weyland  Industries          </a>      </li>      <li><a  href="#">Stark  Industries</a></li>      <li><a  href="#">Cyberdyne  Systems</a></li>   </ul>
  • 45. 8. To escape the dropdown
  • 46. For keyboard-only users, the ESC keystroke should close the dropdown and return focus to the button.
  • 47. 7. To navigate through items within the dropdown
  • 48. When focus has shifted to the <ul> element, keyboard-only users should be able to use TAB, SHIFT TAB, UP ARROW or DOWN ARROW to move forwards or backwards through the list items.
  • 49. When users reach the start or end of the list, UP ARROW and DOWN ARROW keystrokes should then have not have any effect.
  • 51. Keyboard-only users should be able to select a dropdown menu item using ENTER and possibly the SPACEBAR keystrokes.
  • 52. 9. To leave the dropdown
  • 53. Keyboard-only users should be able to TAB forward through the dropdown items and then on to other focusable items outside the dropdown.
  • 54. As soon focus leave the last dropdown item, the dropdown should disappear.
  • 55. Users should be able to SHIFT TAB backwards through the dropdown items and back to the button.
  • 56. The dropdown should remain open when the button receives focus. (Users can close the dropdown by triggering the button again).
  • 58. So, that’s it. A few simple pointers to help make button dropdowns more accessible. Thanks for listening!
  • 59. Russ Weakley Max Design Site: maxdesign.com.au Twitter: twitter.com/russmaxdesign Slideshare: slideshare.net/maxdesign Linkedin: linkedin.com/in/russweakley