Browse documentation
Reference / Variants & accessibility
Screen-reader-only content
Keep a label in the accessibility tree while visually clipping it to a one-pixel box. Use not-sr-only to restore ordinary layout.
Working example
The checkbox receives a meaningful accessible name from the label. A concise visible label is preferable whenever the layout has room.
<label class="inline-flex items-center gap-2 border px-3 py-2">
<input type="checkbox" class="accent-black">
<svg aria-hidden="true" focusable="false" width="16" height="16" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linejoin="round">
<path d="m19 21-7-5-7 5V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z"/>
</svg>
<span class="sr-only">Bookmark this edition</span>
</label>Class reference
| Class | CSS declarations |
|---|---|
sr-only | position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0; |
not-sr-only | position: static;
width: auto;
height: auto;
padding: 0;
margin: 0;
overflow: visible;
clip: auto;
white-space: normal; |
focus:not-sr-only | position: static;
width: auto;
height: auto;
padding: 0;
margin: 0;
overflow: visible;
clip: auto;
white-space: normal; |
View full generated CSS
.not-sr-only {
position: static;
width: auto;
height: auto;
padding: 0;
margin: 0;
overflow: visible;
clip: auto;
white-space: normal;
}
.sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border-width: 0;
}
.focus\:not-sr-only:focus {
position: static;
width: auto;
height: auto;
padding: 0;
margin: 0;
overflow: visible;
clip: auto;
white-space: normal;
}