Preview
HTML
<form>
<fieldset>
<legend>View</legend>
<input id="modern-a" type="radio" name="modern-panel" checked />
<label for="modern-a">Type</label>
<input id="modern-b" type="radio" name="modern-panel" />
<label for="modern-b">Space</label>
<p class="a">Tokens for type.</p>
<p class="b">A single gap.</p>
</fieldset>
</form>
CSS
:root {
--ink: #111111;
--paper: #ffffff;
--accent: #e10600;
--accent-2: #111111;
--on-accent: #ffffff;
--muted: #5c5c5c;
--line: #111111;
--chip: #f2f2f2;
}
fieldset {
display: flex;
flex-wrap: wrap;
gap: 0.4rem;
margin: 0;
padding: 1rem 1.1rem;
border: 1px solid var(--line);
border-radius: 0.45rem;
background: var(--paper);
color: var(--ink);
font-family: system-ui, sans-serif;
}
legend { font-weight: 650; }
input { position: absolute; opacity: 0; }
label {
padding: 0.3rem 0.65rem;
border-radius: 0.45rem;
font-size: 0.92rem;
font-weight: 650;
}
input:checked + label {
background: var(--accent);
color: var(--on-accent);
}
p {
flex: 1 0 100%;
display: none;
margin: 0.4rem 0 0;
}
input:nth-of-type(1):checked ~ .a,
input:nth-of-type(2):checked ~ .b {
display: block;
}
Tailwind
<style>
:root {
--ink: #111111;
--paper: #ffffff;
--accent: #e10600;
--accent-2: #111111;
--on-accent: #ffffff;
--muted: #5c5c5c;
--line: #111111;
--chip: #f2f2f2;
}
input:checked + label {
background: var(--accent);
color: var(--on-accent);
}
input:nth-of-type(1):checked ~ .a,
input:nth-of-type(2):checked ~ .b {
display: block;
}
</style>
<form>
<fieldset class="flex flex-wrap gap-[0.4rem] m-0 p-[1rem_1.1rem] [border:1px_solid_var(--line)] rounded-[0.45rem] bg-[var(--paper)] text-[var(--ink)] font-[system-ui,_sans-serif]">
<legend class="font-[650]">View</legend>
<input class="absolute opacity-[0]" id="modern-a" type="radio" name="modern-panel" checked />
<label class="p-[0.3rem_0.65rem] rounded-[0.45rem] text-[0.92rem] font-[650]" for="modern-a">Type</label>
<input class="absolute opacity-[0]" id="modern-b" type="radio" name="modern-panel" />
<label class="p-[0.3rem_0.65rem] rounded-[0.45rem] text-[0.92rem] font-[650]" for="modern-b">Space</label>
<p class="a [flex:1_0_100%] hidden m-[0.4rem_0_0]">Tokens for type.</p>
<p class="b [flex:1_0_100%] hidden m-[0.4rem_0_0]">A single gap.</p>
</fieldset>
</form>