[Accordion] expose internal Context #1106
-
Hello folks 👋 Background: Implementing a RadioAccordionI recently needed to implement an Accordion where we can only open a single item at a time, with a Radio as its triggering element. The UX expects to let user choose a configuration method between different values, then displays extra data for this configuration. simplescreenrecorder-2022-01-21_14.57.43.mp4I am reusing primitive components and following Radix-UI pattern to allow combining the different parts together: I expose I decided to try combining Radio Group and Accordion primitives. NeedBecause of the implementation behind context + controlled componentsI am forced to add a layer of context providers/consumers to share information ( Inside my It means I add 2 contexts on top of the existing ones. To fill the selected value for Do you think it would be possible to expose the components' different contexts to allow a simpler customization? nest two buttonsAlso, I notice I am nesting two I am looking into a workaround here. Comments welcomeAny guidance or opinion would be largely appreciated. I am part of a team working on an open-source library: https://github.com/traefik/faency I'm totally open to sharing ideas if they're bringing value to your awesome project. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Hi @seedy, Am I understand correctly that you are using both
I think your accordion "styling" is perfectly sensible. In my mind what this is is simply an accordion, which happens to visually style the "active" state using a design similar to a radio item. Does that make sense? |
Beta Was this translation helpful? Give feedback.
-
I have a use case where in an The use case is that in these accordions there is a preview version of the content, and the actual content, and animation is done through an external library. I'd like to add |
Beta Was this translation helpful? Give feedback.
Hi @seedy,
Am I understand correctly that you are using both
Accordion
andRadioGroup
primitives together for this?If so I believe this is wrong and this kinda highlights the point:
I think your accordion "styling" is perfectly sensible.
However, to me, the fact that it "looks" like a radio is just that: "styling".
It has nothing to do with accessibility, and in fact, mixing both patterns will result in broken accessibility.
In my mind what this is is simply an accordion, which happens to visually style the "active" state using a design similar to a radio item.
So I think that should be…