- Implementation
- SrOnly Props
Usage Guidelines
UseSrOnly when assistive technology needs text that should not appear on screen. SrOnly visually hides content while keeping it in the accessibility tree.Alternatives
aria-labeloraria-labelledbyfor naming a control without extra DOM text.aria-describedbypointing 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-onlyclass ina2-utils.cssfor the same visual-hide behavior without the React component.
How to Use
ImportSrOnly and place the screen-reader text next to the decorative content.SrOnly is a span and accepts standard span props, including id for aria-describedby.Common Examples
TheSrOnly 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
SrOnlyis read by screen readers but not visible - Uses CSS techniques that maintain content in the accessibility tree
- Preserves all standard
spanelement functionality