-
-
Notifications
You must be signed in to change notification settings - Fork 357
Expand file tree
/
Copy pathnested-accordion.tsx
More file actions
75 lines (72 loc) · 2.91 KB
/
Copy pathnested-accordion.tsx
File metadata and controls
75 lines (72 loc) · 2.91 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import React from "react";
import {
Accordion,
AccordionHeader,
AccordionBody,
} from "@material-tailwind/react";
export function NestedAccordion() {
const [open, setOpen] = React.useState(1);
const [openNest, setOpenNest] = React.useState(0);
const handleOpen = (value) => setOpen(open === value ? 0 : value);
const handleOpenNest = (value) => setOpenNest(openNest === value ? 0 : value);
return (
<>
<Accordion open={open === 1}>
<AccordionHeader onClick={() => handleOpen(1)}>
What is Material Tailwind?
</AccordionHeader>
<AccordionBody className="p-3">
We're not always in the position that we want to be at.
We're constantly growing. We're constantly making mistakes.
We're constantly trying to express ourselves and actualize our
dreams.
{/* Nested Accordions */}
<Accordion open={openNest === 1}>
<AccordionHeader onClick={() => handleOpenNest(1)}>
What is Material Tailwind?
</AccordionHeader>
<AccordionBody>
We're not always in the position that we want to be at.
We're constantly growing. We're constantly making
mistakes. We're constantly trying to express ourselves and
actualize our dreams.
</AccordionBody>
</Accordion>
<Accordion open={openNest === 2}>
<AccordionHeader onClick={() => handleOpenNest(2)}>
What is Material Tailwind?
</AccordionHeader>
<AccordionBody>
We're not always in the position that we want to be at.
We're constantly growing. We're constantly making
mistakes. We're constantly trying to express ourselves and
actualize our dreams.
</AccordionBody>
</Accordion>
</AccordionBody>
</Accordion>
<Accordion open={open === 2}>
<AccordionHeader onClick={() => handleOpen(2)}>
How to use Material Tailwind?
</AccordionHeader>
<AccordionBody className="p-3">
We're not always in the position that we want to be at.
We're constantly growing. We're constantly making mistakes.
We're constantly trying to express ourselves and actualize our
dreams.
</AccordionBody>
</Accordion>
<Accordion open={open === 3}>
<AccordionHeader onClick={() => handleOpen(3)}>
What can I do with Material Tailwind?
</AccordionHeader>
<AccordionBody>
We're not always in the position that we want to be at.
We're constantly growing. We're constantly making mistakes.
We're constantly trying to express ourselves and actualize our
dreams.
</AccordionBody>
</Accordion>
</>
);
}