JSFiddle - React, Tailwind, and code Playground
by Mandar Badve
HTML
<h1>The <code>details</code> element displayed inline</h1>
<details>
<summary>Document</summary>
Effective Date: 25 06 2024
</details>
CSS
details {
display: inline-block;
}
summary {
list-style: none;
display: inline-flex;
align-items: center;
padding: 10px;
font-weight: bold;
}
summary::after {
content: '';
width: 18px;
height: 10px;
background: url('https://uploads.sitepoint.com/wp-content/uploads/2023/10/1697699669arrow.svg') no-repeat;
background-size: cover;
margin-left: .75em;
transition: 0.2s;
}
details[open]>summary::after {
transform: rotate(180deg);
}
summary::-webkit-details-marker {
display: none;
}
summary {
background-color: #a3d4fb;
color: #30353b;
border-radius: 5px;
}
details[open] summary {
border-radius: 5px 5px 0 0;
}
details {
border-radius: 5px;
}
/* extra styles */
* {
box-sizing: border-box;
}
body {
font-family: system-ui, sans-serif;
margin: 20px;
background: #fff9f1;
}
h1 {
font-size: 1.2em;
}
article>*:first-child {
margin: 0;
}
article>*+* {
margin: 0.75em 0 0 0;
}
pre {
color: white;
background: #2c2330;
padding: 1em;
border-radius: 5px;
}
article {
padding: 10px;
margin: 0;
background: #a3d4fb;
border-radius: 0 5px 5px 5px
}
details code {
font-size: 1.1em;
}