Add Custom Wishlist Button in Header Content in Magento 2

If you are looking for customization of the Magento 2 header content then you are on the right page. In this article, I am going to explain how we can add Custom Wishlist Button in the Magento 2 header content.

This button will add before the mini cart button in the top header bar so our order will be look something like catalog search, Wishlist, mini cart links in header content, now read all the files for what's the proper code to add that.

Custom Add To Wishlist Button
Custom Add To Wishlist Button


Magento 2 Add Custom Wishlist Button in Header Content

So we have to create a minimum of four files to add a custom wishlist button in header content






Step 1:

Now first we have to register our module so we have created a file which is registration.php


* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.



Step 2:

Now we have to create a file for module information which is module.xml


<?xml version="1.0"?>
<config xmlns:xsi="" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Wishusucess_CustomWishlist" setup_version="1.0.0" />


Step 3: Add Custom Wishlist Button

We have to create a default.xml file and through this layout XML, we can add and remove view elements and their data so we will add wishlist content here.


<?xml version="1.0"?>
<page xmlns:xsi="" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceContainer name="header-wrapper">
<block class="Magento\Wishlist\Block\Link" name="wish-list-link-custom" after="minicart" template="Wishusucess_CustomWishlist::link.phtml" />


Step 4: Add Templates File

Here you can style your button as per your requirement.


/* you can customize the wishlist here */
float: right;
} .counter.qty {
background: #ff5501;
color: #fff;
height: 24px;
line-height: 24px;
border-radius: 2px;
display: inline-block;
margin: 3px 0 0;
min-width: 18px;
overflow: hidden;
padding: 0 3px;
text-align: center;
white-space: normal;

.wishlist-custom:before {
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-size: 22px;
line-height: 28px;
color: #757575;
content: '\e600';
font-family: 'luma-icons';
margin: 0;
vertical-align: top;
display: inline-block;
font-weight: normal;
overflow: hidden;
speak: none;
text-align: center;

.wishlist-custom .text{
border: 0;
clip: rect(0, 0, 0, 0);
height: 1px;
margin: -1px;
overflow: hidden;
padding: 0;
position: absolute;
width: 1px;
<div class="custom link wishlist" data-bind="scope: 'wishlist'">
<a <?= /* @noEscape */ $block->getLinkAttributes() ?> class="wishlist-custom">
<span class="text"><?= $block->escapeHtml($block->getLabel()) ?></span>
<!-- ko if: wishlist().counter -->
<span data-bind="text: wishlist().counter" class="counter qty"></span>
<!-- /ko -->
<script type="text/x-magento-init">
"*": {
"Magento_Ui/js/core/app": {
"components": {
"wishlist": {
"component": "Magento_Wishlist/js/view/wishlist"



Now Run The Following Command to See Wishusucess Wish List Button:

php bin/magento setup:upgrade

php bin/magento setup:di:compile

php bin/magento setup:static-content:deplpy -f

php bin/magento cache:clean


Download This Extension:



Related Post:

Wishusucess AdminMenu: How to Create Magento 2 Admin Menu Module

HelloWorld Extension: How to Create Hello World Module


Recommended Post:

Magento 2.4 Installation Guide: How to Install Magento 2.4.2

Magento Store: Best 36 Magento Websites Example in The World