Skip to main content
For development, import SrOnly from @servicetitan/anvil2. For design, find it in the Anvil2 file.

Usage Guidelines

Use SrOnly when assistive technology needs text that should not appear on screen. SrOnly visually hides content while keeping it in the accessibility tree.

Alternatives

  • aria-label or aria-labelledby for naming a control without extra DOM text.
  • aria-describedby pointing at visible helper text when the description can be shown to everyone.
  • Visible Text or FieldLabel when sighted users also need the content.
  • The sr-only class in a2-utils.css for the same visual-hide behavior without the React component.

How to Use

Import SrOnly and place the screen-reader text next to the decorative content.
Content stays in the accessibility tree. SrOnly is a span and accepts standard span props, including id for aria-describedby.

Common Examples

The SrOnly component renders content that is visually hidden but remains accessible to screen readers. This is essential for providing context to assistive technology users without affecting the visual design.

React Accessibility

  • Content in SrOnly is read by screen readers but not visible
  • Uses CSS techniques that maintain content in the accessibility tree
  • Preserves all standard span element functionality
For more guidance on semantic page structure, see semantic markup best practices.
Last modified on November 10, 2026