Inspired by Netflix's FAQ section
- Live Site URL: https://react-accordion-ishant.netlify.app/
- Animation on expansion
- Icon rotate on expansion
- Dynamic height for expanded cards
Clone the project
git clone git@github.com:ishantbhurani/react-accordion.git
Go to the project directory
cd react-accordion
Run
npm start
- ReactJS
- JSX
- CSS
- Fetching element properties (such as height) dynamically using
useRef
hook - Smooth animation for card expansion
useEffect(() => {
if (expandedID === id) {
const height = contentRef.current.getBoundingClientRect().height;
containerRef.current.style.height = `${height + 10}px`;
} else {
containerRef.current.style.height = 0;
}
}, [expandedID]);
- John Smilga - dynamic height with
useRef
hook
- Twitter - @IShaunt
- Design inspiration: Netflix