I'm trying to figure out how to create a mega menu with custom css only / no extensions ?

I copied over the Magento/Catalog/Plugin/Block/Topmenu block to begin. But not sure what to do next or where to find the HTML.

1 Answer 1


IN magento2, menu's html is generate from Magento\Theme\Block\Html;e

At this class's

  • _getHtml(). first level menu items
  • _addSubMenu() add sub menu HTML code for current menu item.ne

Basic this block class generate Html content for menu

Add the menu.js (vendor/magento/module-theme/view/frontend/web/) used at Menu

For *css use less file _navigation.less at **vendor\magento\theme-frontend-blank\web\css\source**.

  • Thanks Amit, when I copy over Magento\Theme\Block\Html\Topmenu and run my page I get this error: [message] => Uncaught TypeError: Argument 2 passed to Magento\Theme\Block\Html\Topmenu::__construct() must be an instance of Magento\Framework\Data\Tree\NodeFactory, array given, called in /var/www/business/app/code/Comapny/Topmenu/Block/Html/Topmenu.php on line 52 and defined in /var/www/business/vendor/magento/module-theme/Block/Html/Topmenu.php:46
    – Kara
    Commented Sep 29, 2017 at 20:56
  • Please share code of /var/www/business/app/code/Comapny/Topmenu/Block/Html/Topmen‌​u.php.
    – Amit Bera
    Commented Oct 1, 2017 at 4:26

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.