defaultValue Prop Not Working as Expected in Radix UI Accordion with Dynamic Children #2724
Unanswered
vladimirzb
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Also same thing is happening on the Resizable Panel in shadcn/ui for me, defaultValue prop does not actually do anything. I'm thinking maybe it has to do with the component needing to be in a flex box or something? |
Beta Was this translation helpful? Give feedback.
1 reply
-
The list of strings you put in the <AccordionItem value="item-1"> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Description:
I'm using Radix UI's Accordion component in a Next.js project and encountering an issue where the
defaultValue
prop doesn't seem to work when the Accordion's children are dynamically generated. Despite settingdefaultValue
, the accordion items do not open by default as expected.Code Snippet:
Here's how I've set up my accordion components:
Page code:
ClientSideAccordionManager:
AccordionContentWrapper:
Expected Behavior:
I expect the accordion item specified in the
defaultValue
prop to be open by default when the page loads.Actual Behavior:
The accordion does not open any items by default, regardless of the
defaultValue
specified.Question:
Could the issue be related to how the
children
prop is used or possibly a misunderstanding of howdefaultValue
should work with dynamically generated children? Any insights or suggestions on how to resolve this issue would be greatly appreciated.Beta Was this translation helpful? Give feedback.
All reactions