7 ms·
Anyone got a good feel for the htmx accessibility story at the moment? I'm interested in using it more, but I want to be 100% confident that I understand how t
by simonw 2y ago
Anyone got a good feel for the htmx accessibility story at the moment?
I'm interested in using it more, but I want to be 100% confident that I understand how to get htmx sites to work well with screen readers. I worry about things like fetching new data into a page not altering the screen reader user in the same way as refreshing a page completely would.
I'm not interested in whether or not htmx uses the correct ARIA attributes - I want to be confident that those ARIA attributes (or similar) do the right thing.
My ideal is still to use JavaScript libraries where the documentation not only describes how they work with screen readers, but is accompanied by video evidence showing the experience a screen reader user gets for different problems solved by that library.
- 1propionyl 2y agoHandling ARIA attributes is out of scope for HTMX. It is your responsibility to include ARIA attributes on the HTML you return and swap/transclude. As for handling dynamic content for screen readers, focus management is already a thing, and is in the scope of browser standards and the HTML your backend returns. As before, it's your responsibility to manage this. HTMX will neither help you nor get in your way. HTMX merely extends hypertext functionality to its (mostly) natural conclusion. It is not a component library, or a framework for building components, or a site building framework, or... You can use other tools to enhance and audit accessibility, but their use is orthogonal to HTMX. I think web developers in general are very used to frameworks abstracting a ton of complexity, but HTMX is not a framework so much as a standardized set of tools for specific low level problems, it is not a one stop shop.
- simonw 2y agoIn that case it would be great if the HTMX documentation included worked examples and guidance for how to do this. Leaving accessibility up to the end developer feels like a genuine missed opportunity for me here. One of the great things about NOT using a JavaScript library is that you can rely on the browser's default accessibility features for forms and links. Those benefits are the thing I care most about when considering HTMX or jQuery or React or Vue or similar.
- 1propionyl 2y ago> In that case it would be great if the HTMX documentation included worked examples and guidance for how to do this. You can refer to the WAI-ARIA standards. > Leaving accessibility up the end developer feels like a genuine missed opportunity. This doesn't compute for me. What would HTMX even provide? It's a set of attributes that extend the behavior of form submission to other elements and all request methods. > HTMX or jQuery or React/Vue These aren't the same kinds of tools. They address fundamentally different things. Handling ARIA automatically for you isn't in scope for any of them.
- simonw 2y agoReferring to the ARIA standards doesn't help me answer the more important question: will what I'm doing work in screen readers or not? I feel completely starved of information here. I care about accessibility. I want to build a web page where clicking on a tab refreshes a subset of that page... and I still can't find a really good guide on how to do that in a way that works in screen readers, that's accompanied by a video (ideally multiple videos, one for each common screen reader) showing the experience I can expect my users to have from that pattern. HTMX actively encourages that pattern, so I'd love to see the project also embrace helping developers do The Right Thing with regards to the accessibility of that pattern.
- ossobuco 2y ago> will what I'm doing work in screen readers or not? Why not try it? But also, why wouldn't it?
- robin_reala 2y agoPointing at the ARIA spec as a way of writing code that’ll work with all assistive tech is like pointing at the HTML and CSS specs circa 2005 and saying that following them will make your site work in all browsers.
- xg15 2y ago
- nodamage 2y ago> I worry about things like fetching new data into a page not altering the screen reader user in the same way as refreshing a page completely would. Isn't this more of a general browser question that would apply to any website that uses Javascript to load page elements? How would using HTMX (as opposed to any other library, or plain old Javascript) affect the answer to the question?
- simonw 2y agoYeah, any website that uses JavaScript to load page elements needs to solve this. My hope is that a library like HTMX can help reduce the friction in implementing the best possible patterns for doing so.
- ThibWeb 2y agoSee the proposed moveBefore API [1] which is meant to solve those issues at the platform level. In the meantime, htmx has their morphdom extension, which I’d say is a must when replacing any page content with interactive elements within. Aside from that one major gotcha, the main issues with htmx are the poor accessibility of the examples in the docs [2]. In particular seeing so much ARIA without the corresponding keyboard support. [1] https://htmx.org/examples/move-before/ https://htmx.org/examples/move-before/ [2] https://github.com/bigskysoftware/htmx/issues/1431 https://github.com/bigskysoftware/htmx/issues/1431
- alexpetros 2y agoHey Simon, maintainer + article co-author here. tl;dr htmx is better than a lot of alternatives, but Simon is right, it can improve this story and it has a responsibility to do so. As a framing device: any interactivity that is not described with HTML is interactivity that someone is responsible for making accessible (which you correctly pointed out). Unlike JS frameworks, htmx encourages the developer to solve problems with HTML first, so the inaccessible surface area that the developer has to worry about is going to be much smaller on htmx-based applications than it is with JS-based applications. That's a pretty strict win from where a lot of the industry is right now. That having been said, I agree with you (and disagree with a lot of our defenders in the comments) that thinking about this is in-scope for htmx. In fact, I'm a firm believer that libraries are exactly where responsibility for implementing ARIA attributes live. The average web developer should not have to think about this at all—they should be able to use declarative abstractions and trust that they are annotated correctly for screen readers. This is the only system that scales, and htmx should adhere to it as much as possible. Ideally, htmx would just add the polite notification attribute to the elements it processes, and give an easy way to customize that. I think it's basically possible to do this in a backwards-compatible way (first as an extension) that aligns with the maintenance strategy outlined in this essay. And I do think we can improve the documentation as well.
- simonw 2y agoI'm thrilled to hear you're thinking about this. I really like the philosophy of the project, very happy to hear that reducing accessibility friction is a value you care about too.
- yawaramin 2y agoI would argue that frontend libraries like htmx and React are not the place to build in ARIA attributes patterns/behaviours. In fact, none of the Big Ones do anything specifically w.r.t. announcing changes. See https://news.ycombinator.com/item?id=42625070 https://news.ycombinator.com/item?id=42625070 What would be the appropriate place, imho, would be component frameworks that are built on top of htmx. FastHTML is an example; they already have htmx integration and they talk about server-side components. If we look at a popular one in React, this is what they do: https://blog.logrocket.com/aria-live-regions-for-javascript-frameworks/#react-a11y-announcer-react https://blog.logrocket.com/aria-live-regions-for-javascript-... Thinking about it in terms of dream-html[1], it might look like: let announce msg = p [ class_ "announcement"; Hx.swap_oob "innerHTML:.announcement"; Aria.live `polite; ] [txt "%s" msg] (* POST /purchase *) let purchase request = let thank_you_fragment = ... in Dream_html.respond ( (* Join fragments together *) null [ thank_you_fragment; announce "Your purchase has been successful!"; ] ) [1] https://github.com/yawaramin/dream-html https://github.com/yawaramin/dream-html
- imacrayon 2y agoThis is one reason I created https://alpine-ajax.js.org https://alpine-ajax.js.org. A few years ago there were a lot of examples in the HTMX documentation that discouraged accessibility and progressive enhancement. Stuff like like clickable <div>s, ignored keyboard focus, lack of screen reader announcements. There’s been some improvement latel, but I still think the library has a lot of foot guns for new web developers.
- FartinMowler 2y agoThank you for alpine-ajax! It's amazing as an HTMX-lite or HTMX-just-right in many many use cases.
- imacrayon 2y agoYou made my day! thanks
- reassess_blind 2y agoI understand screenreaders have a set of standards, aria tags etc - but are the next generation of AI screenreaders (I’m sure some already use AI?) going to replace the need for these tags, and just read a page as a human would?