---
title: "Magento 2: How to Add Custom Button in Minicart"
url: "https://magecomp.com/blog/magento-2-add-custom-button-in-minicart/"
date: "2021-07-13T15:36:19+00:00"
modified: "2025-02-19T05:06:14+00:00"
author:
  name: "Dhiren Vasoya"
  url: "https://magecomp.com/"
categories:
  - "How To"
  - "Magento 2"
word_count: 1051
reading_time: "6 min read"
summary: "Hello Magento Friends,"
description: "Minicart can be customized according to your needs. Adding a custom button to the mini cart can increase the user experience. Learn Magento 2: How to Add Cus..."
keywords: "How To, Magento 2"
language: "en"
schema_type: "Article"
related_posts:
  - title: "How to restrict your customer from adding the product to cart in Magento 2"
    url: "https://magecomp.com/blog/restrict-customer-adding-product-cart-magento-2/"
  - title: "How to Get CMS Block Collection in Magento 2?"
    url: "https://magecomp.com/blog/get-cms-block-collection-magento-2/"
  - title: "How to Programmatically Check Whether a Database Table Contains a Specified Column in Magento 2?"
    url: "https://magecomp.com/blog/programmatically-check-database-table-contains-specified-column-magento-2/"
---

# Magento 2: How to Add Custom Button in Minicart

_Published: July 13, 2021_  
_Author: Dhiren Vasoya_  

![How-to-Add-Custom-Button-in-Minicart-in-M2](https://magecomp.com/blog/wp-content/uploads/2021/07/How-to-Add-Custom-Button-in-Minicart-in-M2-1024x512.webp)

**Hello Magento Friends,**

Today’s Magento solution is on Magento 2: How to Add Custom Button in Minicart.
A small cart icon on the top-right of the webpage is a mini cart that displays the summary of the products added to the cart. The customers can view their cart items without leaving the shopping process.
[![Magento 2 Speed & Performance Optimization Services](https://magecomp.com/blog/wp-content/uploads/2023/10/Magento-2-Speed-Performance-Optimization-Services-CTA-4.webp)](https://magecomp.com/magento-performance-optimization.html)

Although you can customize the mini cart according to your requirements in Magento 2. Sometimes the admin needs to add a custom button in the mini cart and perform some action on this button. Adding a custom button to the mini cart increases the user experience as the customers can perform actions without leaving their buying process.
Follow the below steps to Add a Custom Button in Minicart of your Magento 2 Store.
## Steps to Add Custom Button in Minicart in Magento 2:
**Step 1:** First, we need to create a **“default.xml”** file inside the extension at the following path.
**app\code\Vendor\Extension\view\frontend\layout\**

Now add the below code
```
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="header-wrapper">
            <referenceBlock name="minicart">
                <arguments>
                    <argument name="jsLayout" xsi:type="array">
                        <item name="components" xsi:type="array">
                            <item name="minicart_content" xsi:type="array">
                                <item name="config" xsi:type="array">
                                    <item name="template" xsi:type="string">Vendor_Extension/minicart/content</item>
                                </item>
                            </item>
                        </item>
                    </argument>
                </arguments>
            </referenceBlock>
        </referenceContainer>
    </body>
</page>
```

**Step 2:** After that, we need to create a **“requirejs-config.js”** file inside the extension at the following path.
**app\code\Vendor\Extension\view\frontend\**

And add the code as mentioned below
```
var config = {
    config: {
        mixins: {
            'Magento_Checkout/js/view/minicart': {
                'Vendor_Extension/js/view/minicart-mixin': true
            }
        }
    }
};
```

**Step 3:** After that, we need to create a **“minicart-mixin.js”** file inside the below path
**app\code\Vendor\Extension\view\frontend\web\js\view\**

Then, add the below-mentioned code
```
define([
    'uiComponent',
    'Magento_Customer/js/customer-data',
    'jquery',
    'ko',
    'underscore',
    'sidebar',
    'mage/translate',
    'mage/dropdown'
], function (Component, customerData, $, ko, _) {
    'use strict';

    var mixin = {
        isButtonEnable: function () {
           /* you need to add your custom code here */
            return true;
        }
    };

    return function (target) {
        return target.extend(mixin);
    };
});
```

[![hyva theme development](https://magecomp.com/blog/wp-content/uploads/2025/02/hyva-theme-development-CTA-5.webp)](https://magecomp.com/services/hyva-theme-development/)

**Step 4:** After that, we need to create a **“content.html”** file inside the below path
**app\code\Vendor\Extension\view\frontend\web\template\minicart\**

After that, include the code as follows
```
    <strong>
                            </strong>

    <button type="button"
            id="btn-minicart-close"
            class="action close"
            data-action="close"
            data-bind="attr: { title: $t('Close') }">
            </button>

    <if args="getCartParam('summary_count')">
                                <translate args="'of'" if="maxItemsToDisplay < getCartLineItemsCount()"/>
                            <!-- ko if: (getCartLineItemsCount() === 1) -->
                                    <!--/ko-->
                <!-- ko if: (getCartLineItemsCount() > 1) -->
                                    <!--/ko-->

        <each args="getRegion('subtotalContainer')" render=""/>
        <each args="getRegion('extraInfo')" render=""/>
        <if args="isButtonEnable()">
				    		        <button  type="button"
		                class="action primary checkout custombutton"
		                data-action="close"
		                translate="'Send Quote'"/>
		    		        </if>
				    		        <button
		                id="top-cart-btn-checkout"
		                type="button"
		                class="action primary checkout"
		                data-action="close"
		                data-bind="
		                    attr: {
		                        title: $t('Proceed to Checkout')
		                    },
		                    click: closeMinicart()
		                "
		                translate="'Proceed to Checkout'"
		        />
		        		    		    </if>

    <if args="getCartParam('summary_count')">
        <strong class="subtitle" translate="'Recently added item(s)'"/>
                    <ol id="mini-cart" class="minicart-items" data-bind="foreach: { data: getCartItems(), as: 'item' }">
                <each args="$parent.getRegion($parent.getItemRenderer(item.product_type))"
                      render="{name: getTemplate(), data: item, afterRender: function() {$parents[1].initSidebar()}}"
                />
            </ol>
            </if>

    <ifnot args="getCartParam('summary_count')">
        <strong class="subtitle empty"
                data-bind="visible: closeSidebar()"
                translate="'You have no items in your shopping cart.'"
        />
        <if args="getCartParam('cart_empty_message')">
            <p class="minicart empty text" text="getCartParam('cart_empty_message')"/>
                                                <a class="action viewcart" data-bind="attr: {href: shoppingCartUrl}" data-wpel-link="internal" target="_blank" rel="follow">
                                            </a>
                                    </if>
    </ifnot>

                        <a class="action viewcart" data-bind="attr: {href: shoppingCartUrl}" data-wpel-link="internal" target="_blank" rel="follow">
                            </a>

            <each args="getRegion('promotion')" render=""/>
    <each args="getRegion('sign-in-popup')" render=""/>
```

**Step 5:** Finally, after adding the code you need to run Magento upgrade and deploy commands.
Once you implement the above steps, your custom button is successfully added to the mini cart of your Magento 2 store.
## Conclusion:
This way you can successfully Add Custom Button in Minicart in Magento 2. You can also implement other customizations with your mini cart in order to increase the customer experience.
- [**Magento 2: Show Count 0 on Mini Cart when No Product is in Cart**](https://magecomp.com/blog/magento-2-show-count-0-on-mini-cart-when-no-product-is-in-cart/)
- [**How to Show Minicart in Custom Popup In Magento 2**](https://magecomp.com/blog/show-minicart-custom-popup-magento-2/)

Just in case you are stuck anywhere with the implementation of the above steps, let me know via the comment box. Share the article with your friends and stay in touch with us for more solutions.
[![Hire Magento Programmer](https://magecomp.com/blog/wp-content/uploads/2025/02/Hire-Magento-Programmer-CTA-4.webp)](https://magecomp.com/services/hire-magento-programmer/)

**Happy Coding!**

</body>


---

_View the original post at: [https://magecomp.com/blog/magento-2-add-custom-button-in-minicart/](https://magecomp.com/blog/magento-2-add-custom-button-in-minicart/)_  
_Served as markdown by [Third Audience](https://github.com/third-audience) v3.5.3_  
_Generated: 2026-09-15 10:54:02 UTC_  
