21

The recurring failure: models give me pretty hover effects that vanish for keyboard users, remove the focus outline "because it's ugly", or convey state with color alone. I got tired of fixing the same three things.

So I wrote an accessibility-first interaction prompt with an explicit banned list and a requirement that every hover has a matching :focus-visible treatment. It also forces a non-color state cue and a reduced-motion branch. The outputs finally pass an axe scan on the first try.

Sharing it. Would love additions from folks who test with actual screen readers, not just automated tools.

THE PROMPT
Style interactive elements (links, buttons, a card) with hover/focus states that are accessible by default. Requirements:
- Every `:hover` effect has an equivalent `:focus-visible` effect. Never style hover alone.
- Keep a visible focus indicator: `:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }`. NEVER `outline: none` without an equally visible replacement.
- State must not rely on color alone: pair color changes with an underline, weight, icon, or transform so it survives grayscale.
- Transitions: only `transform`, `opacity`, `background-color`, `color`, `outline-color`; duration 120-180ms; easing `cubic-bezier(0.2, 0, 0, 1)`. No transitions on `all`.
- Hit target minimum 44x44px for touch.
- Wrap motion in `@media (prefers-reduced-motion: reduce)` to disable transforms/transitions but KEEP the color/underline state change.
Banned patterns: `outline: none` alone, `:hover`-only styling, color-only state, `transition: all`, removing underlines from links without another affordance.
Output CSS with a one-line comment above each rule saying which requirement it satisfies.
144px touch target in the same prompt as focus rings, yes. Motion people forget the finger; a11y people forget the mouse. This does both.motion_mina 1 month ago
Screen reader note: also ask it not to convey the ONLY label via an icon font glyph. Add a visually-hidden text label.layout_lou 1 month ago
add a comment

1 Answer

13

The transition: all ban alone is worth the price of admission, it's the #1 cause of accidental jank when you later add a box-shadow. I'd add one line: forbid transition-delay on focus states. A delayed focus ring feels broken to keyboard users because the highlight lags their tabbing.

THE PROMPT
Add to banned list: no `transition-delay` on `:focus-visible`. The focus ring must appear instantly.

Your Answer