-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAccordion.jsx
34 lines (34 loc) · 976 Bytes
/
Accordion.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { useState } from "react";
import { IoChevronDown } from "react-icons/io5";
const Accordion = ({ title, options }) => {
const [activeAccordion, setActiveAccordion] = useState(false);
return (
<div
onClick={() => {
setActiveAccordion(!activeAccordion);
}}
className="w-full max-w-[500px] bg-white p-3 rounded-lg cursor-pointer"
>
{/* accordion header */}
<div className="flex justify-between items-center">
<p>{title}</p>
<IoChevronDown
className={`${
activeAccordion && "rotate-180"
} duration-200 delay-200`}
/>
</div>
{/* accordion body */}
{activeAccordion && (
<div className="bg-zinc-100 p-3 rounded-lg mt-4 text-sm">
<ul>
{options.map((option, index) => {
return <li key={index}>{option}</li>;
})}
</ul>
</div>
)}
</div>
);
};
export default Accordion;