Skip to content

Screen Reader Utilities

Utilities for hiding content visually while keeping it accessible to screen readers.

ClassPurpose
af-sr-onlyVisually hidden. Accessible to screen readers.
af-sr-only-focusableHidden until focused. Generic; skip links use af-skip.

Hides an element visually but keeps it in the accessibility tree. Screen readers will still announce it.

<!-- Icon button with accessible label -->
<button class="af-btn af-btn-icon">
  <span class="af-sr-only">Close</span>
  ×
</button>

<!-- Accessible table caption -->

<table>
  <caption class="af-sr-only">Quarterly revenue by region</caption>
  ...
</table>
  • Icon-only buttons that need a text label
  • Decorative images with adjacent visible text
  • Table captions when a visual heading already exists
  • Additional context for screen reader users

Hidden until the element receives focus. Use this for custom hidden-until-focus controls. Skip links use af-skip — it includes this clip plus position and chrome.

<a href="#settings" class="af-sr-only-focusable">Skip to settings</a>
.af-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border-width: 0;
}

.af-sr-only-focusable:not(:focus, :focus-within) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border-width: 0;
}