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.

umiarkowanastatyczneWCAG 2.1.1 · Afe-tailwind

Dlaczego

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.

Poprawka

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.

Przykłady

<!-- 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>

Źródła

Fakty

Identyfikator
tailwind/hover-only-reveal
Waga
umiarkowana
Sprawdzanie
statyczne sprawdzane w kodzie źródłowym przez audit
Dotyczy plików
html angular vue svelte astro jsx
Tylko w projektach z
tailwind
WCAG 2.2
2.1.1, poziom A
Uczy jej skill
fe-tailwind Tailwind CSS
Od wersji
0.1.0

Plik reguły na GitHubie

Przeczytaj w terminalu

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