I tried to change the my account link to a image but then found that it was called in xml in vendor/magento/module-customer/view/frontend/layout/default.xml as label .

So how could I change it to image instead of label.

I also tried to add a custom block having a image in the place of my account label but it doesnt workout.

Can anyone say how to change the label my account label to a image or icon?

my account link


You have to pass an arguments in default.xml for add class in account link:

<block class="Magento\Customer\Block\Account\Link" name="my-account-link">
       <argument name="label" xsi:type="string" translate="true">My Account</argument>
       <argument name="class" xsi:type="string" translate="true">custom-account-link</argument>

Then, you can add css in custom-account-link class to display image or icon.

  • so, Do i have to set it as background image right? @RoshanHapani – Haerriz Feb 17 '20 at 7:30
  • Yes............. – Rohan Hapani Feb 17 '20 at 8:31

For this you have to add class using xml file and add background images using css file.

Step 1: app/code/VendorName/ModuleName/view/frontend/layout/default.xml

My Account account link

Step 2: app/code/VendorName/ModuleName/view/frontend/web/css/accountlink.css

.account-link { background-image: url("https://www.w3schools.com/cssref/paper.gif"); }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.