How to change a button style on magento

How to change a button style on magento

September 3, 2026 · Illustrated author avatarBy Stefan Bogdanescu
How to change a button style on magento

Changing Button Styles on Magento: A Comprehensive Guide

We’ve all been there - you have a Magento store that’s doing great, but those default add-to-cart buttons are just not cutting it anymore. They’re dull, they don’t match your brand, and they’re holding back your sales potential. Today, we’ll walk through exactly how to change those button styles to something more appealing and on-brand.

Identifying the Buttons

Before diving in, let’s identify which buttons you want to style:

  1. Add-to-Cart Button: The most common target.
  2. Wishlist Button: For saving products for later.
  3. Compare Button: Allows customers to compare similar items.

Understanding Magento Templates

Magento follows a template-driven structure. Each button’s style is defined in a template file located under app/design/frontend/{your_package}/{your_theme}/template/catalog/product/view. The main files include:

  • view/addtocart.phtml for the add-to-cart button.
  • view/compare.phtml for the compare button.
  • view/wishlist.phtml for the wishlist button.

Changing Button Styles

Let’s use your provided CSS as an example. Here’s how to apply it:

Step 1: Create a new CSS file

Navigate to your theme directory under app/design/frontend/{your_package}/{your_theme}/web/css. Create a new file named something like custom-buttons.css.

Step 2: Add the custom styles

Open your newly created custom-buttons.css file and paste the provided CSS code:

.classname {
    /* Paste your button style rules here */
}

.classname:hover {
    /* Hover state rules */
}

.classname:active {
    /* Active state rules */
}

Now, you need to link this new stylesheet to your Magento theme. Open app/design/frontend/{your_package}/{your_theme}/theme.xml and add a reference to your new CSS file inside the block:

<reference name="head">
    <action method="addItem">
        <type>skin_css</type>
        <name>css/custom-buttons.css</name>
        <params/>
        <if>
            <condition>default/</condition>
        </if>
    </action>
</reference>

Step 4: Update the Buttons

Now, let’s update the button templates to use your new styles.

  1. Add-to-Cart Button: Open app/design/frontend/{your_package}/{your_theme}/template/catalog/product/view/addtocart.phtml. Find this line:
<button type="button" title="<?php echo $this->getButtonTitle() ?>" class="button addtocart-button<?php if($addToCartClass): ?> <?php echo $addToCartClass; ?><?php endif; ?>" id="product-addtocart-button-<?php echo $_id ?>"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
  1. Replace it with:
<button type="button" title="<?php echo $this->getButtonTitle() ?>" class="classname"><span><span><?php echo $this->__('Add to Cart') ?></span></span></button>
  1. Repeat this process for the compare.phtml and wishlist.phtml files, replacing .addtocart-button with your new CSS class name (in this case, classname).

Wrapping Up

That’s it! Now when customers visit your Magento store, they’ll see those stylish, on-brand buttons you’ve always wanted.

Remember to clear the website cache after making these changes for them to take effect. You can do this in Magento 2 by going to System > Cache Management and selecting all checkboxes before clicking “Flush Magento Cache”.

If you need more advanced customizations or want to learn about other styling options, check out Laravel Company’s guide on Magento theme development. It provides a comprehensive overview of the process.

Happy styling!

Checkout Catalog Themes Customers

Our network