May 14, 2022
There are times when you want to make a part of a website visually hidden, but not hidden to a screen reader that someone with a vision impairment would use to browse the web.
For example, you have a button with an icon, but you also want to add a bit of text to describe that icon to someone who can’t see the icon. That way, they’ll still know what the button does.
For these situations, you can use Tailwind’s .sr-only
class. It makes things visually hidden, but keeps them around so assistive technologies can still see them.
For example, here’s how you could label a button containing an icon:
<button>
<svg><!-- icon here --></svg>
<span class="sr-only">Add New Task</span>
</button>
Tufts Meal Plan Wrapped
Mar 2, 2024
Building an e-ink picture frame that displays an iCloud photo album
Jan 9, 2024
2023 in review
Jan 5, 2024
Subscribe to my newsletter for a monthly round-up of new blog posts and projects I’m working on!