-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add sr-only and not-sr-only utilities #964
Conversation
I'm not usually a "if it's not broken, don't fix it" kind of guy...but when you're talking about web accessibility and standards that's the answer I would give you. I'd stick to the implementation that's used by governments and companies with a lot of money on the line: Bootstrap's. I'm still not sure what the blog post is trying to fix or improve. A smaller class in CSS? What do you want in that CSS class? To be reliable and tested or to be a couple lines shorter? |
This is awesome, great to see that tailwind is making this easier for people. For what it's worth maybe firing up a few screen readers is the best way to test the classes. Seem like they would work though 😁 (not an expert) |
You don't need a tabindex on the skip link. It's an anchor tag with an href attribute. The element is already focusable. |
the UK govt has a really decent team working on accessibility have their blog has so much on it. If you search stuff like GDS + Topic, normally something good e.g. https://accessibility.blog.gov.uk/2017/02/08/advice-for-creating-content-that-works-well-with-screen-readers/ loads of content and explanations on YouTube. https://youtu.be/JHaLzm-FGsc This is great to help understand the complexity of forms if you really want to make really accessible interfaces |
@adamwathan HTML5 Boilerplate switch to |
This is great, the first thing I do when I start a project with Tailwind is take |
I've been using the https://github.com/webdna/tailwindcss-visuallyhidden plugin, but I think that it would be a great addition to Tailwind core. |
Does anyone know why tools like this are needed when we have |
I think that ARIA and roles like |
@garygreen Powermapper did a test recently with a few, common browser + screen reader combinations: JAWS, NVDA and VoiceOver are the most commonly used screen readers and JAWS + IE is at the top in usage. Another thing for css driven |
This is awesome as a core plugin!!! Thank you for this work. Just a heads up that VoiceOver has a nasty bug where it inverts the order of screen reader text and reads things backwards, which I've tracked down to the presence of For those interested, here are the references where others have hit the same issue, and @NickColley has done extensive testing with different assistive technologies. |
Yeah I've seen this, and the proposed solution to fixing this is the one I mentioned in the original comment of this thread: I don't have enough experience with this stuff to test it properly though, so I'm hesitant to deviate from Bootstrap. If this ends up being the better solution I'm sure they will update their class and we can follow suit. |
Gotcha. I didn't realize that updated snippet from the blog post referenced was also dealing with the inverted reading. Gonna read that now. 👍 |
I should've just linked to the GitHub thread, the blog post doesn't mention it until the end, heh. |
Interesting, I dug into bootstrap's version a bit and it looks like the v5 dist file has an updated sr-only class. I know v5 hasn't been officially released yet, but good to know they're giving attention to it. https://github.com/twbs/bootstrap/blob/master/dist/css/bootstrap.css#L7139-L7157
|
It's changed a bit even since then, our implementation is based on this recent PR: Only real difference is they changed how they are handling the focusable side of things which we will always do differently just due to the nature of Tailwind, but the implementation of |
We (Bootstrap) changed the implementation of the .sr-only,
.sr-only-focusable:not(:focus) {
position: absolute !important;
width: 1px !important;
height: 1px !important;
padding: 0 !important;
margin: -1px !important;
overflow: hidden !important;
clip: rect(0, 0, 0, 0) !important;
white-space: nowrap !important;
border: 0 !important;
} We don't have the ability to generate responsive classes like tailwind has though, might be something to look into later The reason why we used the The latest implementation is available via this url: https://twbs-bootstrap.netlify.com/docs/4.3/helpers/screen-readers/ |
Truly the weirdest bug I've ever seen. Do you know when it shows up in practical situations? The |
The issue I linked to is the only scenario I know of. |
Going to merge this as-is despite the VoiceOver issue because it's good enough for Bootstrap and it's better than offering nothing. We can refine this in the future if a more bullet-proof solution ever surfaces. |
This PR adds a new
accessibility
core plugin that includessr-only
andnot-sr-only
utilities.Their implementation is as follows:
sr-only
is based on Bootstrap's implementation, with one notable difference being that we useborder-width: 0
to remove the border instead ofborder: 0
. This is to prevent blowing out our default Preflight border styles, so that if you need to applynot-sr-only
to an item, the border utilities will start working as expected.not-sr-only
simply resets all of the properties set bysr-only
. This class is useful if you want to make something visible at larger breakpoints but keep it visually hidden at smaller ones:It can also be used with the
focus
variant modifier to make a visually hidden element appear when focused:If anyone has any feedback or suggested changes to this implementation let me know!
This blog post suggests that this implementation might actually be better than Bootstrap's:
...but since it hasn't been adopted yet by Bootstrap or HTML5 Boilerplate I'm a little hesitant to use it, since there might be issues that haven't been uncovered by mass usage.