React Aria: A headless UI component library
react-spectrum.adobe.com
react-spectrum.adobe.com
In other words, it would be nice to have slices of UI behavior defined more orthogonally in a way which can be more freely layered, and it seems like this is a step in that direction.
From the user perspective, yet another widget with subtly different behaviour is very annoying. I'd much rather you add drag and drop handling to the existing widget so that everyone benefits and UIs remain consistent.
<rant>
Hell, back in the 2000s, even web apps used native widgets, and we shamed websites that implemented their own UIs in Flash because they were bloated and inaccessible. Now we do it in Javascript and it's considered okay, even though all the same objections apply. And with Electron apps we've managed to combine all the worst aspects of web apps and native apps - they're slow, non-native and not cross-platform, and don't have text search, and still have to be installed.
</rant>
But the users' expectations are set by their cumulative (read: across all apps) broader experience. If a high percentage of your users have a certain expectation for Interaction X and the app is not that (tho' consistent within the application) those users will likely be disappointed.
Of course some components + UX are truly unique. Perhaps the crux of your killer app / killer feature. Unfortunately, this is not as often as most ppl think; thus too much time is wasted making unique those things which are better off frictionless and forgettable.
It is however quite extensive as you can see by the role definitions:
https://www.w3.org/TR/wai-aria-1.1/img/rdf_model.png
Don't know if that is still best practice, screen readers probably are way smarter today.
I work on Plasmic (plasmic.app), a visual builder for React. With react-aria, we're able to let our users build, say, a Select component visually however they want, and then we just use the hooks to spread the right props to the right elements, and It Just Works. See https://youtu.be/mPHS2zg2a8Y
Headless UI is an exciting space. There's only so far you can go with re-skinning material ui or antd, and no one should be building their own from scratch. These headless libraries give you all the interactivity and accessibility you need for your components, but still give you total freedom over how they look. It is the way!
The maintainers are super responsive+helpful on Github and really know how to engage constructively with criticism.
I really appreciate what they're doing. The combination of TailwindCSS+React Aria provides one with a pretty great template/scaffolding for building out a fully featured component library.
The only downside that I've found is that their typescript support can be a little weird in my experience, but their approach is nonetheless well considered imo. edit: https://github.com/adobe/react-spectrum/pull/1761#issuecomme... is a decent summary of what I'm referring.
IMO the community is much better served by tools that help you identify accessibility gaps during the design phase, experience your application in other usage paradigms, or audit third party packages for accessibility before taking them as dependencies. If you work with designers who love hover triggered tooltips with forms with more tooltips inside them this library cannot fix the fact that you're making a terrible experience. If you want to npm install React-ported Kendo components because you "remember they worked well with jQuery" this library will not make them accessible. Turn voiceover on, turn your screen off, eat your own dog food.
What's worse "accessibility helper libraries" like this often get used as an excuse to say "of course we made this accessible look at all the helpers in the code" but the team never actually audits to see what the experience is like (hint: your Lighthouse accessibility score does not indicate WCAG compliance), and surprise surprise they've incorrectly implemented the helpers in a way that actually degrades the experience. Then they pay my agency a lot of money to hurry up and do it the right way before the NFB lawsuit drops.
Here's a good example of deep thinking and investigative work that goes into react-aria: https://react-spectrum.adobe.com/blog/building-a-combobox.ht...
It would be cool to go back to HTML=schematics and CSS=styling.
Maybe CSS needs to become more capable tool to place divs more easily?
What's the issue now then? Flexbox is straightforward enough.
I can see the appeal of web components when your interop issues are as large Adobe’s must be. On the other hand if huge portions of your apps are canvas / wasm then web components’ DOM-centric component model might feel awkward or constraining
People constantly have to reinvent the wheel to offer fairly basic functionality, so it’s good that there are libraries to handle the behaviour and accessibility side well while supporting whatever visual styles you want to make.
I think it’s still best to build on the native elements first though.
https://www.merrickchristensen.com/articles/headless-user-in...
"What does it even do then" you ask. It implements basic accessibility patterns so you only deal with high level UI elements and not have to worry about having the correct `role-` or `aria-` attributes. That and composite elements such as tabs or modals
Why no style? Most product teams have a design system and they actually overwrite the style of component libraries anyway. So better to have component libraries without style, less bloat.
If there were a standard library (adopted by all browsers) similar to the default look of iOS and Android apps, but in return you couldn't customize the look, would y'all go with that?
Give me the primitives any day.
I was looking at Alpine.js but it's pretty minimal, so I want something more full-featured to compare to. These headless UIs look useful, and some have React and Vue versions.
The server-side mostly just takes place if you utilize the following: - Built-in API - Server-side Rendering
NextJS (and Gatsby) occupy this space between a static site and a site that is sever rendered. While the site itself is static, during the build process is when all the "server side" stuff happens.
one pitfall of react that it fixed for me was escaping the single page gracefully.
for example, if you want to have any other /pages that can be shared properly on facebook / get index on a search engine, then you NEED to render that on the server (can be statically generated with next.js so you still don't need a server)
doing routing with pure react is a complete headache and mess of code, plus it will not get indexed properly / look right on a search engine.
if you start with next.js, you lose none of the react functionality, add very little overhead, and can actually make a functioning website a lot more easily.
like i said, i rejected it to begin with too - but it is super useful and super easy to use. don't make my mistakes all over again!
Some libraries will offer a ton of props to customize different parts of a component - and for some use cases, that is enough. But sometimes it is just easier to structure and style the component however you want, with custom behavior sprinkled in, and then letting a library like react-aria take care of the rest.
Try building a fully accessible dropdown from scratch in React? This is what these libraries solve.
An example from Radix UI: https://youtu.be/pcMYcjtWwVI
Headless CMSes are useful as well once you exit the realm of blogs and WYSIWYG website builders.
Some of my tweets showing how we do this:
- https://twitter.com/devongovett/status/1318600389462126592 - https://twitter.com/devongovett/status/1270410802395111424 - https://twitter.com/devongovett/status/1318676759080968193