Tailwind CSS

tailwind/hover-only-reveal

Content or controls revealed with hover: are also revealed on focus (focus-within:, group-focus-within:), never on hover alone.

moderatestaticWCAG 2.1.1 · Afe-tailwind

Why

opacity-0 group-hover:opacity-100 on a card's "Edit" and "Delete" buttons shows them only to a mouse. A keyboard user tabs onto controls they cannot see, and since Tailwind 4 wraps hover: in @media (hover: hover), a phone user never sees them at all.

Fix

Add the focus variant beside every hover reveal: group-hover:opacity-100 group-focus-within:opacity-100 (or focus-visible: on the control itself). Better still, keep important actions visible and use hover only to emphasise them.

Examples

<!-- bad -->
<div class="opacity-0 group-hover:opacity-100"><button type="button">Edit</button></div>
<!-- good -->
<div class="opacity-0 group-hover:opacity-100 group-focus-within:opacity-100"><button type="button">Edit</button></div>

Sources

Facts

Id
tailwind/hover-only-reveal
Severity
moderate
Check
static checked in the source by audit
Applies to
html angular vue svelte astro jsx
Only in projects with
tailwind
WCAG 2.2
2.1.1, level A
Taught by the skill
fe-tailwind Tailwind CSS
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain tailwind/hover-only-reveal