-
-
Notifications
You must be signed in to change notification settings - Fork 557
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP - Post: Pitfalls of accessible components #1490
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,90 @@ | ||||||||||||||||||
--- | ||||||||||||||||||
title: Pitfalls of accessible components | ||||||||||||||||||
description: | ||||||||||||||||||
category: Background | ||||||||||||||||||
author: Erik Kroes | ||||||||||||||||||
date: 2022-11-30 | ||||||||||||||||||
last_updated: 2022-11-30 | ||||||||||||||||||
tags: | ||||||||||||||||||
- background | ||||||||||||||||||
--- | ||||||||||||||||||
|
||||||||||||||||||
No matter how beautiful your building blocks (components) are, you can still build wrong with them! | ||||||||||||||||||
More and more you see that components claim to be accessible. That sounds good: components that can be used by everyone, including people with disabilities! It is not always clear what exactly such a claim entails. In addition, it does not give you any guarantees as a builder. You can still make a mess! | ||||||||||||||||||
What can go wrong? We look at some common pitfalls. | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Personal preference, but I try to avoid terms like "look", "see", etc. given the audience this site serves, unless it is directly referencing a specific behavior. |
||||||||||||||||||
|
||||||||||||||||||
## What are components good for? | ||||||||||||||||||
|
||||||||||||||||||
Components are great for anything you need to do more than once. You don't want to design and build your button or link every time. That's a waste of your time. You would rather build one version that is very good, and then you can reuse it. Why often build something halfway, if you can spend all that time in one very good version? You can then test that one version with different browsers, mobile, with screen readers and hopefully even with real users! | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Flipped this to plead to component's use case, then broke into two paragraphs as they are two separate thoughts. This will also help lower the overall reading level. |
||||||||||||||||||
What you immediately get is consistency. You make everyone happy with that! For example, consider a focus state that is the same everywhere. That takes a lot of thinking. | ||||||||||||||||||
|
||||||||||||||||||
<figure role="figure" aria-label="It's all in the application."> | ||||||||||||||||||
<img alt="A plastic playset is placed on the roof edge of an appartment building." src="/img/posts/pitfalls-of-accessible-components/playset.png" /> | ||||||||||||||||||
<figcaption>It's all in the application.</figcaption> | ||||||||||||||||||
</figure> | ||||||||||||||||||
Comment on lines
+21
to
+24
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤣 |
||||||||||||||||||
|
||||||||||||||||||
## Page-specific: content | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I was a little confused about this heading until I read further. What do you think about this phrasing? |
||||||||||||||||||
|
||||||||||||||||||
One page is not the other. And it is precisely in the parts that vary that things can of course still go wrong. | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little unclear what this means. Could we revise? |
||||||||||||||||||
|
||||||||||||||||||
### Content | ||||||||||||||||||
|
||||||||||||||||||
A bit of a tinkering perhaps, but good to be aware of. You write content for every page. It must be accessible. You can think of avoiding complex language, and avoiding descriptions based on specific senses (such as an "open the red link" or "the text to the right of this"). | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I removed the first sentence as I was less confused reading through this section with its removal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Added a newline for the new paragraph. |
||||||||||||||||||
Content also goes beyond paragraphs and text blocks. Don't forget your alternate texts for images, or captions and transcripts for other media files. | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
|
||||||||||||||||||
### The page title | ||||||||||||||||||
|
||||||||||||||||||
Match this as much as possible with the main heading on your page (the `<h1>`) and the names of the links pointing to the page. If there are repeating parts in the title (such as the name of the website), place them as far back in the title as possible. This makes scanning (also with screen readers) easier. The unique and distinctive part comes first. | ||||||||||||||||||
In a webshop you get something like: “Product - category - webShopName.nl” | ||||||||||||||||||
Comment on lines
+35
to
+38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm unclear how this relates to components. |
||||||||||||||||||
|
||||||||||||||||||
## Page-specific: structure | ||||||||||||||||||
|
||||||||||||||||||
Perhaps you have something reusable for this, such as templates. That's very nice. However, experience shows that these are not always available and do not have priority. | ||||||||||||||||||
Comment on lines
+40
to
+42
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm also unclear how this relates to components. Are you suggesting that page layout is part of a component abstraction strategy? |
||||||||||||||||||
|
||||||||||||||||||
### Landmarks | ||||||||||||||||||
|
||||||||||||||||||
You want to have your landmarks in order for each page: | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we link to what landmarks are, for readers who may be unfamiliar? Maybe the MDN? |
||||||||||||||||||
- Place your navigation in a `<nav>` | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we rephrase this so it doesn't accidentally imply that all navigation goes into one single |
||||||||||||||||||
- Place the most important content in a `<main>` | ||||||||||||||||||
- Use a `<header>` at the beginning of your page and a `<footer>` at the end | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do all pages have headers and footers? |
||||||||||||||||||
- Do you have information aside? Then use a `<aside>` | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use a synonym for the first use of "aside"? |
||||||||||||||||||
|
||||||||||||||||||
### Heading structure | ||||||||||||||||||
|
||||||||||||||||||
Your headings help people navigate through your page. Just like you can scan headlines in a newspaper, you want to do the same on a website. | ||||||||||||||||||
The `<h1>` is for the main heading; for what your page is about. Below that you want to create a kind of tree structure of your headings. All content logically (both visually and in code) falls under one of your headings. You go from main topic (`<h1>`) to sub-topic (`<h2>`), to sub-sub-topic (`<h3>`), and so on. Never move forward more than one step at a time. | ||||||||||||||||||
Comment on lines
+54
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Newline for a new paragraph. |
||||||||||||||||||
|
||||||||||||||||||
### Focus Order | ||||||||||||||||||
|
||||||||||||||||||
Make sure that every page you tab through navigates logically. This is easier if you don't use a tab index with a value higher than 0. Creative application of CSS grid or flexbox can also cause the visual order to differ from that in the code. | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need to massage this paragraph some, in that it may imply you want to use Flex/grid order also is a bit of niche circumstance, so we might want to rephrase it as something to be on the lookout for to not do. |
||||||||||||||||||
Do you want to make it completely easy for your visitor? Add a skip link. That is a (often hidden) link at the beginning of the page that allows you to "jump" to the content. | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Jump to what content? Where? How often? Maybe we also link to this post! |
||||||||||||||||||
|
||||||||||||||||||
## Difficult to test | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a bit of a surprise in that there wasn't a companion "Easy to test" section before this one. Is that something we'd want to work in for the previous content? |
||||||||||||||||||
|
||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One thing I try to do is not have a heading followed by another heading, as some folk might think there's missing content. Can we have a segue sentence or tow to introduce the following content and why you consider it difficult? |
||||||||||||||||||
### Variations of components | ||||||||||||||||||
|
||||||||||||||||||
The more features a component has, the greater the chance that it will go wrong. If a component has a boolean attribute, dark mode and two responsive zoom levels, then you quickly end up with (2x2x3=8) eight variations that all need to be tested and maintained. So pay attention to this! If everyone around you has default dark mode on, you can count on issues in light mode. | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we link to a good definition of what a boolean is, for folks who might not be familiar with the term? |
||||||||||||||||||
|
||||||||||||||||||
### Composition | ||||||||||||||||||
|
||||||||||||||||||
As soon as you start combining components, you can also foresee problems. You would prefer, for example, that forms have been developed and bundled as a complete system. You often combine the same components in forms. If they are delivered separately, unexpected (and untested) situations may arise. Another point of attention! | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is the first time we've really mentioned components. I'm thinking the intro might need a bit more detail to clarify what I'm guessing is the structure of the post. |
||||||||||||||||||
Related to this is also the topic of relationships. Everything you tie together yourself is prone to errors. If you have a table of contents at the top of your page, you should pay close attention to how it is connected to the content of your page. Or how about a form (field) and an error message or instruction? You want relationships to be clear both visually and in code. | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
How? |
||||||||||||||||||
|
||||||||||||||||||
<figure role="figure" aria-label="The right parts in the wrong order."> | ||||||||||||||||||
<img alt="A projector is attached to a wall. A projection screen is rolled up on the wall above it. The screen can't be rolled out, making it so the projector can't project on it." src="/img/posts/pitfalls-of-accessible-components/projector-and-screen.jpg" /> | ||||||||||||||||||
<figcaption>The right parts in the wrong order.</figcaption> | ||||||||||||||||||
</figure> | ||||||||||||||||||
|
||||||||||||||||||
|
||||||||||||||||||
### Website-wide | ||||||||||||||||||
|
||||||||||||||||||
As mentioned earlier, components are good for consistency. If your set of components is not yet very mature or complete, this can still be a point of improvement. | ||||||||||||||||||
For example, focus states can still differ between pages and components if this is not well thought out and implemented centrally. | ||||||||||||||||||
Another point for improvement in the broader structure is often the navigability. You want pages to be found and accessed in more than one way. Think of a search function or sitemap next to your menu structure. Typically something you can't solve with a component. Make sure all your pages are part of this and are clearly represented. | ||||||||||||||||||
Comment on lines
+81
to
+83
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Newlines for new paragraphs. |
||||||||||||||||||
|
||||||||||||||||||
## Beyond the pitfalls | ||||||||||||||||||
|
||||||||||||||||||
Now imagine watching out for all these pitfalls. Are you sure it's going to be okay? No Unfortunately! You can still choose the wrong component for example! You have no guarantee for an accessible end result. The chance that you will succeed with accessible components is many times greater than without! | ||||||||||||||||||
Components are like the foundation of a house. Are you building on quicksand with crooked window frames? Good luck! A solid foundation with quality parts is what you want. But even with that you can build a house that falls short! | ||||||||||||||||||
Comment on lines
+87
to
+88
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Paragraphs. |
||||||||||||||||||
|
||||||||||||||||||
![A curved and cornered wall with a baseboard. The baseboard is split up in separate pieces in a futile attempt to follow the shape of the wall.](/img/posts/pitfalls-of-accessible-components/baseboard.png) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.