Skip to content
easeweb
Search topics

Card actions that only appear on hover

A product grid keeps its Save and Add to bag buttons hidden until the pointer rests on a card, so nothing else ever shows them.

WCAG 2.2
SC 2.1.1ASC 1.4.13AA· new in 2.1
Required by
Section 508 · EN 301 549 (EU)
Broken .card:hover .actions { visibility: visible; }
The accessibility problem illustrated: Motor:How do I save it?
01

The problem

People who use a keyboard, a switch, a screen reader, a touch screen or a magnifier can't find or use a card's actions, because only a resting pointer shows them.

02

Try it

Rest the pointer on a card, then put the mouse aside and press Tab to reach Save.

The panel under the grid says what has focus and whether it can be seen. Can you reach Save and Add to bag without a mouse, and see them when you do?

Broken Can you fix this?

(Press Tab, or rest the pointer on a card)

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Show the actions on focus and on touch screens too, in their own space, or show them on every card all the time.

  1. 1Every action a hover reveals is also shown when the card or the action has focus.
  2. 2On a screen with no hover, the actions are shown without any pointer state.
  3. 3Revealed actions sit in their own space, or Escape hides them without moving focus.
Before

Actions hidden until the card is hovered

<article class="card">  <a href="/tote"><img src="tote.jpg" alt="Linen tote, natural">Linen tote</a>  <p class="price">$48</p>  <div class="actions">    <button type="button">Save</button>    <button type="button">Add to bag</button>  </div></article>
After

Shown on focus and on touch screens too, in their own row

This fix adds no HTML.

Fixing this with an AI coding assistant? Get this guide as Markdown, or get every guide in your coding agent.

04

Design ideas

Actions can stay quiet without hiding.

Five ways to draw the same card’s actions. Point at each card, then put the mouse aside and Tab through them: three show their buttons to every way of using the page, and two only to a mouse.

Passes

  • Linen tote $48
    Outlined pills, always shown The guide’s second fix: small pills in the card’s own ink, 24 pixels tall, that fill on hover and focus. Nothing is hidden, so the keyboard and a phone get the same card.
  • Linen tote $48
    Quiet text actions, underlined on hover The calmest resting look: plain words in #555555, 7.45:1 on white, with no box until hover or focus underlines them. Keep at least 24 pixels of height and space between them so they stay easy to hit.
  • Linen tote $48
    Revealed on hover and on focus The guide’s first fix: the row still waits for the pointer, but :focus-within shows it as soon as Tab reaches the card, a screen with no hover shows it all the time, and it has its own row, so it covers nothing.

Fails

  • Linen tote $48
    Hidden until the card is hoveredWCAG 2.1.1 visibility: hidden takes the buttons out of the Tab order, so the keyboard skips them, and a touch screen never hovers to show them.
  • Linen tote $48
    Transparent row over the cardWCAG 2.4.7 Kept at opacity: 0, the buttons are still in the Tab order, so focus lands on Save while nothing on screen shows it. On hover the row slides over the price, and no key puts it away.
05

Verify the fix

5 checks.

Test with: Keyboard, Mouse, Touch, Zoom, Screen reader

0 of 5 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the card component or the grid's theme changes.

Limits

This is a starting pattern, not a guarantee for every application. The reveal rules assume the actions are plain buttons inside the card; a library's card component may render them elsewhere in the DOM, where :focus-within won't see them. Test on your real grid, with a keyboard, a phone and a magnifier.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

Keep this fixed as your code changes.

Turn guides like this into rules your coding agents and CI follow, then have the result retested with a keyboard and screen readers.

How retests work