Open florian-lefebvre opened 2 years ago
Cc @op-ent/frontend
My opinion : | Name of lib | HeadlessUI | Radix UI (Primitives) |
---|---|---|---|
Package architecture | Contained in the global package @headlessui/react |
Specific package for this component (@radix-ui/react-switch ) |
|
Components | Switch / Group / Label / Description | Switch (visual) / Root (HTML) : Label have to be added manually | |
Accessibility | Great support / Keyboard : Space / Toggle on label or switch click |
Great Support / Keyboard : Space , Enter / More attrib than the other |
The headless ui switch is easier to use and has more components.
The Radix one is less complete but takes well into account the attributes (notably data-
and aria-
).
I think that headless-ui
should be used but with respect to the W3C's specifications.
( based on the docs and their examples included only )
Awesome analysis! Let's go with the Headless ui Switch then
I think we should really consider https://zagjs.com/ when choosing components (even though it doesn't provide logic for a switch component), it's really interesting (and might allow us to build this lib for multiple js frameworks).
In fact we could use @zag-js/toggle
.
We have to decide which library to use for this, either Headless UI or Radix UI Primitives.