How to override top menu and add icon in Magento 2?

I'm using Magento v2 and want to have icons added to each category menu item.? How can I override this?

I added the Attribute for icon in category (Admin)

I need like this

enter image description here


1 Answer 1


Content of Menu is coming from Block Classes

  • \Magento\Catalog\Plugin\Block\Topmenu

  • \Magento\Theme\Block\Html\Topmenu

HTMl is created at \Magento\Theme\Block\Html\Topmenu::_getHtml and \Magento\Theme\Block\Html\Topmenu::_addSubMenu and I think for your requirement you need to override these classes using preference and do what you want.

  • i need icon add in the menu (like image)
    – SNS
    Jan 25, 2021 at 11:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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