ishantbhurani / react-accordion

Home Page:https://react-accordion-ishant.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Accordion with ReactJS

Inspired by Netflix's FAQ section

Table of contents

Overview

Screenshots

desktop-preview

tablet-preview

mobile-preview

Links

Features

  • Animation on expansion
  • Icon rotate on expansion
  • Dynamic height for expanded cards

Run Locally

Clone the project

git clone git@github.com:ishantbhurani/react-accordion.git

Go to the project directory

  cd react-accordion

Run

  npm start

My process

Built with

  • ReactJS
  • JSX
  • CSS

What I learned

  • 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]);

Useful resources

Author

Credits

About

https://react-accordion-ishant.netlify.app/


Languages

Language:JavaScript 67.0%Language:CSS 27.4%Language:HTML 5.5%