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, and once shown over the price, nothing puts them away

02

Try it

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

  • Broken 1: can you reach Save and Add to bag without a mouse, and see them when you do? The line under the grid says what has focus.

  • Broken 2: can you reach Save and Add to bag without a mouse, and see them when you do? Then rest the pointer on a card: can you still read the price, and does Escape put the actions away?

  • Apply a fix. Tab through the cards again. Can you reach Save and Add to bag, and see them when you do?

Broken Can you fix this?

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Show the card actions without needing a hover

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>
What is wrong3 points
  • Without a resting pointer, the actions never show. Only :hover reveals the row.
  • The keyboard never reaches the buttons. Hidden with visibility: hidden, they are out of the Tab order.
  • On a phone, the actions never show. A touch screen never hovers.
After

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

This fix adds no HTML.

How it is fixed5 steps
  1. Give the row its own place under the price, so it covers nothing when it appears and 1.4.13 doesn't ask for a way to dismiss it.
  2. Reveal it on :focus-within as well as :hover. :focus-within matches the card while any element inside it has focus, so the row appears as soon as Tab lands on the card's link, and the buttons after it are visible when focus reaches them.
  3. Flip visibility in the same rule, or the buttons stay out of the Tab order.
  4. Show the row all the time under the hover: none media query. It is true on phones, and on tablets used by touch, where the row would otherwise never show.
  5. Turn the fade off for people who ask for reduced motion.

This fixes both Befores and passes 2.1.1 and 1.4.13. The pointer reveal stays as it was, for everyone who has a pointer.

04

Design ideas

Actions can stay quiet without hiding

Four 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 one only to a mouse.

In the design file

  • Draw the card with its buttons shown and the focus ring on the first one.
  • Draw the card as phones show it, with the buttons always visible.
  • Draw the buttons at least 24 by 24 pixels.
  • Write the ratios next to the colours, at least 3:1 for the button’s outline and 4.5:1 for its text.

Passes

  • Linen tote $48
    Quiet text actions, underlined on hover The calmest card that hides nothing: plain words in #555555, 7.46:1 on white, with no box, turning to the ink and underlined on hover and focus. It costs a line under the price; keep each word 24px tall and 24px from the next, so they stay easy to hit.
  • Icon buttons on the photo, always there A heart and a bag in 36px white circles on the photo’s corners, as many fashion grids draw them. They take no room under the price and are on every card, so Tab and a tap reach them; each needs a name with the product in it, “Save Linen tote”.
  • Linen tote $48
    Add to bag over the photo, put away with Escape A 40px white pill slides up over the bottom of the photo on hover, on Tab and always on a touch screen, and never covers the name or price. Because it covers part of the photo, Escape puts it away without moving the pointer.

Fails

  • Linen tote $48
    Sizes over the photo, on hover onlyWCAG 2.1.1 The fashion-grid shortcut: S, M and L slide up over the photo when it is pointed at, and a tap on one adds that size to the bag. Nothing else shows them, so Tab skips all three and a phone never sees them; show them on focus and on touch, as Add to bag over the photo does.
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. A card whose actions sit inside the card's own link has a different failure, covered in buttons inside card links that also open the page. 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.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service