How to add hover effect to "Add To Cart" becoming Cart icon

Topic summary

A Shopify store owner seeks help adding a hover effect where the “Add To Cart” button transforms into a cart icon when users hover over it.

Initial Problem:

  • User wants the button text to disappear and be replaced by a cart icon on hover
  • Provides before/after screenshots showing desired effect

Solution Provided:
A community member shares custom CSS code to be added to the theme.min.css file:

  • Uses CSS pseudo-elements (::before) with the ‘fontello’ icon font
  • Implements opacity and scale transforms for smooth transition
  • Hides button text on hover while displaying the icon

Follow-up Issues Resolved:

  • Initial code caused button blackout; fixed by adding font-family specification
  • User successfully changed icon from “Cart” to “Bag” by modifying the icon code
  • Applied same logic to “Featured Products” section with minor CSS selector adjustments

Status: Resolved successfully. The solution works across multiple sections of the store. One user notes theme.min.css may not be available in Dawn theme (potential compatibility consideration).

Summarized with AI on November 11. AI used: claude-sonnet-4-5-20250929.

Howdy everyone,

I’m trying to add the hover effect to my “Add To Cart” button to become the cart icon as we hover the mouse over. I would really appreciate it if anyone could help us! Will be a great add-on to the community!

Our website is https://www.rowabi.com/ or https://wabi-element.myshopify.com/

Thanks in advance fellas!

Before hover:

After hovering the mouse over:

1 Like

@RowabiCo

sorry for that issue can you try this code

  1. Go to Online Store->Theme->Edit code
  2. Asset->/theme.min.css ->paste below code at the bottom of the file.
.paymentButtonsWrapper #AddToCart::before {position: absolute;content: "";width: 100%;height: 100%;left: 0;right: 0;top: 12px;content: '\e802';opacity: 0;transform: scale(0);transition: all 0.9s;}
.paymentButtonsWrapper #AddToCart {position: relative;}
.paymentButtonsWrapper #AddToCart:hover::before {}
.paymentButtonsWrapper #AddToCart:hover::before {opacity: 1;transform: scale(1);}
.paymentButtonsWrapper #AddToCart.add-to-cart--secondary:not(.disabled):hover span {display: none;}
1 Like

@KetanKumar I just tried, somehow the Add To Cart is blackout after applying the codes.. I think now if we can add the Cart Icon in the middle of the empty blackout bar, it would be perfect!

1 Like

@RowabiCo

oh sorry for that can you remove last one code and update this

.paymentButtonsWrapper #AddToCart::before {position: absolute;font-family: 'fontello';width: 100%;height: 100%;left: 0;right: 0;top: 12px;content: '\e802';opacity: 0;transform: scale(0);transition: all 0.9s;}
.paymentButtonsWrapper #AddToCart {position: relative;}
.paymentButtonsWrapper #AddToCart:hover::before {opacity: 1;transform: scale(1);}
.paymentButtonsWrapper #AddToCart.add-to-cart--secondary:not(.disabled):hover span {display: none;}

look at this code work

1 Like

@KetanKumar oh my God this is gorgeous, thank you so much!!!

1 Like

To help understand the solution, I just re-format it:

.paymentButtonsWrapper #AddToCart::before {
position: absolute;
font-family: ‘fontello’;
width: 100%;
height: 100%;
left: 0;
right: 0;
top: 12px;
content: ‘\e802’;
opacity: 0;
transform: scale(0);
transition: all 0.9s;
}

.paymentButtonsWrapper #AddToCart {
position: relative;
}

.paymentButtonsWrapper #AddToCart:hover::before {
opacity: 1;
transform: scale(1);
}

.paymentButtonsWrapper #AddToCart.add-to-cart–secondary:not(.disabled):hover span {
display: none;
}

1 Like

@RowabiCo

its my pleasure to help us

1 Like

@RowabiCo

yes, correct

1 Like

@KetanKumar Quick question upon that, do you know how I could change from the “Cart” to the “Bag” icon? :slightly_smiling_face:

1 Like

@RowabiCo

yes, please check your icon font family font-family: ‘fontello’; just change icon code

1 Like

@KetanKumar Perfect works! Appreciate it!!

I’m trying to apply the same logic, for different part (“Featured Products” - Our Best Sellers). However, the “Add To Cart” won’t disappear when the cart shows up, do you know any clues why? Thanks a lot !!

.grid-view-item .quick-add-button::before {
    position: absolute;
    font-family: 'fontello';
    width: 100%;
    height: 100%;
    left: 0;
    right: 0;
    top: 12px;
    content: '\e802';
    opacity: 0;
    transform: scale(0);
    transition: all 0.5s;
}

.grid-view-item .quick-add-button {
    position: relative;
}

.grid-view-item .quick-add-button:hover::before {
    opacity: 1;
    transform: scale(1.3);
}

.grid-view-item .quick-add-button:hover {
  	display: inline;
  	background-color: white;
}
1 Like

@RowabiCo

can you please try this code

button.quick-add-button::before {position: absolute;width: 100%;height: 100%;left: 0;right: 0;top: 12px;content: '\e802';opacity: 0;transform: scale(0);transition: all 0.9s;font-family: 'fontello';color: #000;}
button.quick-add-button {position: relative;}
button.quick-add-button:hover::before {opacity: 1;transform: scale(1);}
button.quick-add-button:hover {color: #eeeeee !important;border-color: #000 !important;}
1 Like

@KetanKumar You are amazing!! Thank you so much!!

theme.min.css not available in dawn theme