JSFiddle - React, Tailwind, and code Playground
HTML
<label class="accordion">
<input type="checkbox" checked>
<h1>This is the header</h1>
<div class="accordion-content">
<p>This is the content of this accordion</p>
</div>
</label>
CSS
h1
{
padding: 0.01em;
margin: 0;
}
h1, p
{
color: white;
}
.accordion
{
border-radius: 0.25em;
background: rgba(0, 0, 0, 0.6);
display: block;
}
.accordion input[type=checkbox] + :after
{
content: "\25B6";
display: inline-block;
padding-left: 0.5em;
transition: transform 0.25s;
}
.accordion input[type=checkbox]:checked + :after
{
transform: rotate(90deg);
}
.accordion input[type=checkbox]
{
display: none;
height: 0;
}
.accordion .accordion-content
{
background: rgba(255,255,255, 0.3);
height: auto;
max-height: 0;
transition: max-height 0.5s;
overflow: hidden;
border-radius: 0 0 0.25em 0.25em;
}
.accordion input[type=checkbox]:checked ~ .accordion-content
{
max-height: 200px;
}