News for hackers. Stuff that matters.
Re:React Aria: A headless UI component library by deltaci on Friday November 05, 2021 @04:44AM (#29116806)
can someone explain in layman terms what is headless UI?
Re:React Aria: A headless UI component library by jokull on Friday November 05, 2021 @04:47AM (#29116824)
"Bring your own UI". You get the behavior from the library but they are completely unstyled or without the component layer where the styles live. Other libraries include Radix and HeadlessUI. Here's a presentation from one of the Radix library authors about how to build dropdowns in React, it serves as a good explainer about what goes into a headless UI library component. https://www.youtube.com/watch?v=lY-RQjWeweo
Re:React Aria: A headless UI component library by spyke112 on Friday November 05, 2021 @05:08AM (#29116945)
Why not just use default html elements?
Re:React Aria: A headless UI component library by deergomoo on Friday November 05, 2021 @05:39AM (#29117121)
They’re pretty lacking. <select> is a great example: no searching/filtering, no ability to have styled/multiline text in <option>s, nor anything that’s not plain text (so no SVG iconography for example).

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.

Re:React Aria: A headless UI component library by jorams on Friday November 05, 2021 @03:14PM (#29123586)
I feel like a big problem here is that the Getting Started starts with a bunch of code that just... outputs a bare button. Starting with something like a combobox would show much more value.
Re:React Aria: A headless UI component library by fnordsensei on Friday November 05, 2021 @05:13AM (#29116974)
Some common, but complex, UI components are hard to get right, especially when it comes to accessibility. Combo boxes in particular come to mind.
Re:React Aria: A headless UI component library by devongovett on Friday November 05, 2021 @11:55AM (#29121069)
Yeah ComboBox is one of the most difficult. We wrote a post about the work that went into ours. https://react-spectrum.adobe.com/blog/building-a-combobox.ht...
Re:React Aria: A headless UI component library by ojkelly on Friday November 05, 2021 @05:38AM (#29117116)
There’s a lot of UI elements that are not in the set of html elements. Sometimes you need different behaviours.

I think it’s still best to build on the native elements first though.

Re:React Aria: A headless UI component library by zettadam on Friday November 05, 2021 @09:23AM (#29118832)
'headless' means you bring your own html structure, the library provides interaction and state exposed by props or hooks. As such, I am not sure Headless UI is headless since they only let you bring your own CSS. At that point, it's a lot easier to create your own set of components that you have full control over than to include another NPM dependency.
Re:React Aria: A headless UI component library by dsego on Friday November 05, 2021 @04:47AM (#29116823)
I think you are supposed to do the rendering, it just gives you the behaviors.

https://www.merrickchristensen.com/articles/headless-user-in...

Re:React Aria: A headless UI component library by conorwade on Friday November 05, 2021 @04:46AM (#29116814)
It give you the behaviours needed to implement a UI component, but it doesn’t give you any styling.
Re:React Aria: A headless UI component library by nsonha on Friday November 05, 2021 @06:19AM (#29117348)
It's not a thing, this is just a term made up on the spot by the author of this article to describe a component library that has no built-in style.

"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.

Re:React Aria: A headless UI component library by andrewingram on Friday November 05, 2021 @08:06AM (#29118055)
I mean, at some point someone made up the term, but it's been floating around for years to describe this exact concept.
Re:React Aria: A headless UI component library by thirdvect0r on Friday November 05, 2021 @06:53AM (#29117551)
HeadlessUI[1] has been around for over a year, it's not a term this author made up

[1] https://headlessui.dev/

Re:React Aria: A headless UI component library by tshaddox on Friday November 05, 2021 @12:12PM (#29121287)
HeadlessUI is one of the newcomers, with a lot of name recognition due to its affiliation with the wildly popular library Tailwind. The term has been around much longer. The first commit of the awesome list was over 3 years ago, and I suspect the term was already fairly established at that point: https://github.com/jxom/awesome-react-headless-components/co...