Designing accessible components

a rock n roll illustration of the a11y hashtag with the ones replaced by a hand making the horns
image source: Heydon Pickering
illustrated avatar of Sarah with cat

Who is this Sarah person?

  • Dojo widgets
  • web accessibility
  • herds cats
dragon logo of the dojo web framework

Designing accessibility? Other developers? What?

Captain Picard incredulously asking 'What does that even mean?'

Today we're talking about:

  • Component libraries
  • Diverse models of user interaction
  • Diverse models of developer meddling

OK but... why do I care?

Crowd of disability rights activists under the sign 'Injustice anywhere is a threat to justice everywhere'
The Rolling Quads. Source: 99 Percent Invisible

Accessibility is:

  • Freedom
  • Privacy
  • Participation
  • Equality

The Curb Cut effect

a wheelchair stopped next two a four inch curb
Necessary
(source: the Smithsonian)
woman pushing stroller up curb cut
Beneficial
(source)
  • Curb cuts
  • Audio captions and transcripts
  • High contrast mode or night mode
  • Distraction-free features
  • An accessible, semantic web?

OK, accessibility. But why make a pattern library?

Meet your coworkers

Mayhem is lurking, in the form of a cadre monster coworkers

profile image of your caveman coworker “If it looks right, I'm done.”
profile image of your zombie intern “What's an ARIA? I don't like opera.”
profile image of your inventive I'll-just-roll-my-own coworker “I need these twenty obscure features, and a pony.”

Flexibility and Control

A rhythmic gymnast doing a split leap while juggling the web components icon

An icon button case study:

Button with text 'I am a button'Button with search icon and textButton only search icon

An icon button in the wild


							<button ng-click="triggerDownload()" class="btn"
							  tooltip="Download as a zip file">
							  <i class="icon-download-alt"></i>
							</button>
						
a screenshot of a button with no visible text and only a download icon
VoiceOver output: "button"

							<button type="button">I'm a button!</button>
						

							<button type="submit">
							  Search
							  <svg role="img" aria-hidden="true">
							    <use xlink:href="#search"></use>
							  </svg>
							</button>
						

							<button type="submit">
							  <svg role="img" aria-labelledby="search-title">
							    <title id="search-title">Search</title>
							    <use xlink:href="#search"></use>
							  </svg>
							</button>
						

Other possibilities:

  • aria-label
  • icon fonts
  • a text node with some fancy .sr-only CSS

None of this is easy!

Reserving control:


							interface ButtonProperties {
							  type: 'submit' | 'reset' | 'button';
							}

							interface IconProperties {
								use: string;
								label?: string;
							}
						

Flexibility

Your inventor colleague is back. Did you miss him?
I also want it to do
[insert 10 extra features, and a pony]

Ponies, popups, oh my!

What could go wrong?

George Takei says oh my to pony buttons

Common button use cases:

  • Submit or reset a form
    type="submit | reset"
  • Open a panel
    aria-expanded="true"
  • Open a menu
    aria-haspopup="menu"
  • Toggle a state
    aria-pressed="true"

Uncommon button use cases

The pink pony of death strikes again

???

Who really knows best?

highly competent and well-dressed golden retriever using a laptop
Definitely this guy

With too many granular details left open-ended...

... you end up with this:


							<button aria-haspopup="true" class="btn btn-popup">
							  Tooltip
							  <svg role="img">
							    <use xlink:href="#plus"></use>
							  </svg>
							</button>
						

or this:


							<button aria-pressed="true" aria-expanded="true"
							  class="btn btn-open btn-pressed">
							  Open Accordion
							  <svg role="img" aria-labelledby="icon-title">
							    <title id="icon-title">Expand accordion</title>
							    <use xlink:href="#plus"></use>
							  </svg>
							</button>
						

But without enough flexibility, your component might be abandoned in favor of this:


							<div role="button" onclick="ponyDance()">
							  Ponies for all
							  <img src="pony.png">
							</div>
						

Build extensibility into:

  • Visual styles
  • Layout
  • Child content

Provide an intuitive API for built-in defaults:


							interface ButtonProperties {
							  type: 'submit' | 'reset' | 'button' | 'toggle'
							        | 'menu' | 'accordion';
							  disabled: boolean;
							  pressed: boolean;
							  open: boolean;
							}
						

Where should you keep control?

  • Accessibility
  • Internationalization
  • Performance
  • ...

Choosing what to build

Extremely cute red panda smiling up at you trustingly. Do not disappoint the red panda.
Not everything is what it seems

Are these both menus?

a screenshot of the google docs editing menu a screenshot of the new york times navigation menu

Don't ask

What it looks like

ask

What it does

Try describing your component's function in a single sentence:

screenshot of a combobox allowing the user to choose a cat, dog, hamster, or goat. Cat is the clearly superior choice.
"A combobox is a normal text input enhanced with a list of suggested options."
screenshot of rows of material design chips showing radio, checkbox, and button functionality
"Chips allow users to enter information, make selections, filter content, or trigger actions."

The limits of a framework

construction worker precariously perched at the edge of a framework of scaffolding

You will never be able to:

  • Write appropriate labels and alt text
  • Take care of overall page structure (landmarks, heading hierarchy, focus order)
  • Account for all possible use cases

Instead:

  • Be realistic up front
  • Provide good usage documentation
  • Educate other developers about diverse interaction patterns

Thank you!