Frontendx
README.md
SOLUTION.md
main.tsxentry
App.tsx
App.css
index.html
vite.config.ts
Installed
react@^19.2.0
react-dom@^19.2.0

Accordion in React

Prompt

Build a reusable accordion component where clicking a section header expands/collapses its content panel. Only one panel can be open at a time (exclusive mode). Smooth height animation on expand/collapse. Accept sections as an array of {title, content} objects.

Store activeIndex in useState. On header click: if activeIndex === i set to null (collapse)
Test Results

Accordion in React

Build a reusable accordion component where clicking a section header expands/collapses its content panel. Only one panel can be open at a time (exclusive mode). Smooth height animation on expand/collapse. Accept sections as an array of {title, content} objects.