Pablo Molina

Visually hidden (sr-only, screen reader only)

🫣 Stressed

Snippet to visually hide elements without losing accessibility.

Currently this is a copy of Bootstrap .sr-only class, but I might update this in the future if I find some simpler solution.

.sr-only:not(:focus):not(:focus-within) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;

Bootstrap's visually-hidden.scss.