x
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<div class="accordion">
<details name="my_accordion">
<summary>Is it accessible?</summary>
<p class="text-sm pbe-4">Yes. It adheres to the WAI-ARIA design pattern.</p>
</details>
<details name="my_accordion">
<summary>Is it styled?</summary>
<p class="text-sm pbe-4">Yes. It comes with default styles that matches the other components' aesthetic.</p>
</details>
<details name="my_accordion">
<summary>Is it animated?</summary>
<p class="text-sm pbe-4">Yes. It's animated by default, but you can disable it if you prefer.</p>
</details>
</div>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<div class="accordion">
<details name="my_accordion">
<summary>Is it accessible?</summary>
<p class="text-sm pbe-4">Yes. It adheres to the WAI-ARIA design pattern.</p>
</details>
<details name="my_accordion">
<summary>Is it styled?</summary>
<p class="text-sm pbe-4">Yes. It comes with default styles that matches the other components' aesthetic.</p>
</details>
<details name="my_accordion">
<summary>Is it animated?</summary>
<p class="text-sm pbe-4">Yes. It's animated by default, but you can disable it if you prefer.</p>
</details>
</div>
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
:where(.accordion) {
details {
border-block-end-width: var(--border);
interpolate-size: allow-keywords;
&::details-content {
block-size: 0;
overflow-y: clip;
transition-behavior: allow-discrete;
transition-duration: var(--time-150);
transition-property: content-visibility height;
}
&[open]::details-content {
block-size: auto;
}
&[open] summary::after {
transform: var(--rotate-180);
}
}
summary {
align-items: center;
cursor: pointer;
display: flex;
font-weight: var(--font-medium);
justify-content: space-between;
padding-block: var(--size-4);
&:hover {
text-decoration: underline;
}
&:focus-visible {
outline: var(--border-2) solid var(--color-selected-dark);
outline-offset: var(--border-2);
}
&::-webkit-details-marker {
display: none;
}
&::after {
background-image: url("chevron-down.svg");
background-size: cover;
block-size: var(--size-4);
content: "";
filter: var(--color-filter-text);
inline-size: var(--size-4);
transition: transform var(--time-200);
}
}
}
Java Script is not required or multiple files are needed, check the notes.