primeflex icon indicating copy to clipboard operation
primeflex copied to clipboard

Screen Reader classes

Open LukMas opened this issue 2 years ago • 2 comments

Screen reader only classes

Having to work with impaired users sometimes we have the need to add extra text because the default, visible and read loud, is not enough for them. Other frameworks/libraries/etc... offer at the moment two classes that support the developers in this:

  • visually hidden
  • visually hidden and focusable

Visually hidden

This class is used to hide an element but show it to the screen reader. No hint about it is even shown, but the screen reader (or another similar technology) will read it as normal text.

Visually hidden and focusable

This class is a bit more evolved than the other one. By default the element is hidden but read from the screen reader. But, once it gets the focus, it becomes visible.

Suggestions and Links

  • Bootstrap (source of the idea) https://getbootstrap.com/docs/5.0/helpers/visually-hidden/
  • Tailwind https://tailwindcss.com/docs/screen-readers
  • https://www.tpgi.com/the-anatomy-of-visually-hidden/

LukMas avatar Apr 24 '23 12:04 LukMas

I also need something like this on a project styled with primeflex.

My solution for now is to borrow this technique suggested by WebAIM:

https://webaim.org/techniques/css/invisiblecontent/

.sr-only {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

chrisbratlien avatar Oct 18 '24 13:10 chrisbratlien

I just realized that my solution was not necessary since PrimeFlex already contains a .p-sr-only class for the same purpose.

chrisbratlien avatar Oct 28 '24 14:10 chrisbratlien