Edit: For size problem, just you need to add following css to container as i add to sample:
align-items:flex-start;
align-content:flex-start;
Problem :
I’m facing some issues with my React application.
First I will explain what I want in my app then I will talk about the issues.
I have a list of 6 Services and I want to wrap each service list in Accordion. Whenever the user clicks the “+” button for the specific service I want that list to be displayed with slides down with a growing margin-bottom, depending on the number of items in the respective list without overlapping the below element.
While trying to achieve this, I’m facing the following issues.
1- when I click “+” button it toggles all 6 services and their list items are getting displayed.
please add a reproducible sample … try codesandbox / stackblitz for making one, then write, save code and share link
Comment posted by SMH
thanks for your reply @KcH. I have added codesandbox link, kindly check the same.
Comment posted by Aliasghar Ahmadpour
Again I checked your codesandbox. you are using single state for all Item review my answer to understand what happend
Comment posted by SMH
@AliasgharAhmadpour, Yes I got it completely. I have to use another state, I check yours and KcH answers both are not addressing to my second question.
Comment posted by SMH
thank you @KcH, it resolves the first issue. But, it still overlaps the below elements. How can I wrap it in accordion and when open, push the below elements down. I want the height of each service to be dynamic which depends on the number of list items.
Comment posted by KcH
yeah, that’s what I’m poor at …. you can probably open a new Q tagging
Comment posted by SMH
thank you for your reply @Aliasghar. It will also overlap the below elements. How can I wrap it in accordion and when open, push the below elements down. I want the height of each service to be dynamic which depends on the number of list items.
Comment posted by SMH
Thank you @Aliasghar, I tried with the above 2 lines of CSS. It gives me all services in one line but my app layout is 3 & 3 as shown in the attached image.