Browse documentation
Reference / Variants & accessibility
Peer states
Read the state of an earlier sibling. An input can reveal helper text or style a label using CSS alone.
Working example
Keep the peer before the elements that depend on it. The generated general-sibling selector matches later siblings under the same parent.
<div>
<input id="include-notes" type="checkbox" class="peer/notes accent-black">
<label for="include-notes" class="peer-checked/notes:font-bold">Include production notes</label>
<p class="mt-2 hidden peer-checked/notes:block">Stock and binding notes will be included.</p>
</div>Class reference
| Class | CSS declarations |
|---|---|
peer-checked:block | display: block; |
peer-invalid:underline | text-decoration-line: underline; |
peer-focus-visible:ring-2 | --mono-ring-offset-shadow: var(--mono-ring-inset,) 0 0 0 var(--mono-ring-offset-width, 0px) var(--mono-ring-offset-color, #fff);
--mono-ring-shadow: var(--mono-ring-inset,) 0 0 0 calc(2px + var(--mono-ring-offset-width, 0px)) var(--mono-ring-color, currentColor);
box-shadow: var(--mono-ring-offset-shadow, 0 0 #0000), var(--mono-ring-shadow, 0 0 #0000), var(--mono-shadow, 0 0 #0000); |
peer-checked/notes:font-bold | font-weight: 700; |
View full generated CSS
@property --mono-ring-offset-shadow {
syntax: "*";
inherits: false;
}
@property --mono-ring-shadow {
syntax: "*";
inherits: false;
}
:where(.peer\/notes:checked) ~ .peer-checked\/notes\:font-bold {
font-weight: 700;
}
:where(.peer:checked) ~ .peer-checked\:block {
display: block;
}
:where(.peer:invalid) ~ .peer-invalid\:underline {
text-decoration-line: underline;
}
:where(.peer:focus-visible) ~ .peer-focus-visible\:ring-2 {
--mono-ring-offset-shadow: var(--mono-ring-inset,) 0 0 0 var(--mono-ring-offset-width, 0px) var(--mono-ring-offset-color, #fff);
--mono-ring-shadow: var(--mono-ring-inset,) 0 0 0 calc(2px + var(--mono-ring-offset-width, 0px)) var(--mono-ring-color, currentColor);
box-shadow: var(--mono-ring-offset-shadow, 0 0 #0000), var(--mono-ring-shadow, 0 0 #0000), var(--mono-shadow, 0 0 #0000);
}