Skip to content

Navigation block: Make nested menus fully customizable (Megamenus) #23745

Open

Description

@adamziel

This is how the current dropdown/nested menu looks like:

Zrzut ekranu 2020-07-7 o 14 26 12

The way it works is that the navigation link block supports nested navigation link blocks. This is fine for simple dropdowns like the one above, but does not support more advanced use cases like the ones below:

Zrzut ekranu 2020-07-7 o 14 19 48

Zrzut ekranu 2020-07-7 o 14 31 26

Zrzut ekranu 2020-07-7 o 14 32 55

Zrzut ekranu 2020-07-7 o 14 33 05

A good start would be supporting an arbitrary wrapper block such as columns, or even some kind of a "box" block that would be like columns with just one column. Supporting a drawer menu at some point would be nice too.

Activity

  1. added
    [Block] Navigation
    Needs Design Feedback
    on Jul 7, 2020
  2. adamziel commented on Jul 7, 2020

    @adamziel
    ContributorAuthor
  3. added
    [Type] Tracking Issue
    on Jul 8, 2020
  4. shaunandrews commented on Jul 8, 2020

    @shaunandrews
    Contributor

    I've been toying with the idea of a Submenu block, which would offer customization options like width and color, along with acting like a specialized Group block that could contain blocks like Columns and Image. Here's a rough GIF to (hopefully) show how it could work:

    Submenu Block

    There's also a clickable Figma prototype you can try.

  5. draganescu commented on Jul 10, 2020

    @draganescu
    Contributor

    This has been discussed in Slack in the weekly navigation sync.

    It's a bit unclear how does a submenu block differ from a group or columns block.

  6. tellthemachines commented on Jul 15, 2020

    @tellthemachines
    Contributor

    I wonder if the Submenu block couldn't instead be a generic Dropdown block, that could also be used elsewhere outside Navigation? And perhaps we could also have a Slideout block, that could contain a Navigation block (or not, it could just contain a bunch of Buttons, or anything else really). The Slideout could just be a wrapper with a close button and <InnerBlocks>.

  7. jasmussen commented on Jan 26, 2021

    @jasmussen
    Contributor

    I wonder if the Submenu block couldn't instead be a generic Dropdown block, that could also be used elsewhere outside Navigation? And perhaps we could also have a Slideout block, that could contain a Navigation block (or not, it could just contain a bunch of Buttons, or anything else really). The Slideout could just be a wrapper with a close button and .

    This is a great idea.

    • The "Slideout" (which is really a better name than "Hamburger") could be a container block which showed a menu button on mobile breakpoints, and its contents on table or desktop breakpoints. Put a navigation block inside, or anything else, and you're golden.
    • The Dropdown block could feature widths (contents width, main column width, wide, fullwide, fullscreen).
    • Combined with the incoming "Page List" block, we could pre-create some delightful navigation block patterns which would give you excellent shortcuts to accomplishing this.
  8. talldan commented on Jan 27, 2021

    @talldan
    Contributor

    Decoupling the link block from its dropdown menu would be great from a code quality point of view as well.

    Jumping into solution space a bit, the part that I'm wondering about is how the block hierarchy will look, especially when it comes to the toggle. Would it be something like:

    Dropdown
        |— Dropdown toggle (only supports a single child block)
        |        |— Link / Button? / Text?
        |— Dropdown menu (supports multiple child blocks)
                 |— Any block (potentially even another dropdown menu)
    

    Alternatively, the Dropdown toggle could be a block without inner blocks, implemented using RichText. With that though there's a risk of losing consistency between how a link with a dropdown menu works compared to a link without a dropdown menu.

  9. tellthemachines commented on Jan 28, 2021

    @tellthemachines
    Contributor

    Could creating a submenu mean that the Link block gets transformed into a Dropdown block, where the toggle content is editable but isn't a separate block, and all its inner blocks go inside the dropdown itself?

  10. talldan commented on Feb 1, 2021

    @talldan
    Contributor

    I think my concern would be about missing features in the Dropdown Block. Things like rel and title attributes would be lost. There has also been investigation into making Page Link dynamically update to changes in URL (e.g. permalink changes). Dropdown would also have to implement that.

    But what you mention would at the moment be best for user experience.

    For my suggestion to work there would need to be improvements to how inner blocks work (e.g. the 'passthrough' block idea)

  11. jasmussen commented on Apr 6, 2021

    @jasmussen
    Contributor

    I've been on an expedition to explore pragmatic next steps for this one. Specifically, I did the crazy thing and allowed the Heading and Columns blocks inside submenus. That's the easy part:

    const ALLOWED_BLOCKS = [
    	'core/navigation-link',
    	'core/spacer',
    	'core/heading',
    	'core/columns',
    ];
    

    Of course that's not going to work for us, but the experiment was nevertheless interesting:

    experiment

    A few immediate take-aways:

    • The heading actually did work, but it's hard to know which heading level to use.
    • Allowing the paragraph instead is arguably a better choice, but that changes the appender to the inline one, which we should avoid here.
    • The columns block works, but it brings with it all the problems it already has — bulky placeholder, fiddly creation flow, yet another container.
    • The columns block does not allow Page Link or any of the other navigation items. So even if we did want to allow a columns block inside submenus, it would come with additional work.
    • The width of submenus is currently based on content — you can see it grow when I type in the heading. But this needs more control.
    • The "Absorb toolbar" mechanism used by the navigation block shows its downsides here. We might want to turn it off again until we can revisit how the mover control can potentially be disconnected from the parent block toolbar, or otherwise make general improvements there.

    But zooming out further, I feel like there are some more general observations we can make:

    • Allowing just the paragraph (but without changing from the button plus appender) seems like a great way to allow subheadings or just arbitrary phrases. Seems like an easy win.
    • Allowing you to set the width of submenus seems like a property we can set on the navigation block itself, like a sidebar toggle. There doesn't seem to be great value in allowing variable-width submenus on a per-dropdown basis.
    • Showing multiple columns, the key bit of mega menus, is likely going to be the primary headache. It seems like it might be worth trying to start with the same approach the Gallery block uses, which is to say provide a number of columns slider in the navigation block sidebar, and then handling the complexity behind the scenes. If we combine this with a column-height value, you should be able to control how many items are in each column, by carefully using spacer blocks, and we'd avoid introducing a ton of nesting complexity in the process.

    I'll try and explore this more in a mockup.

  12. shaunandrews commented on Apr 6, 2021

    @shaunandrews
    Contributor

    Allowing just the paragraph (but without changing from the button plus appender) seems like a great way to allow subheadings or just arbitrary phrases. Seems like an easy win.

    Love the flexibility this could provide.

    There doesn't seem to be great value in allowing variable-width submenus on a per-dropdown basis.

    I actually think a variable-width could be preferred, depending. I'd want to be able to select from some options, maybe [shrink|full-width|fix-width] — though that might be a bigger ask.

    provide a number of columns slider in the navigation block sidebar, and then handling the complexity behind the scenes.

    This setting, and the width setting, would "live" within the inspector for the parent link item?

  13. 16 remaining items

  14. draganescu commented on Jun 21, 2022

    @draganescu
    Contributor

    @cfournel today the submenus of the navigation block are still limited to links and the ability to create "mega menus" is still not there. I think in the images we have design explorations not actual results of using Gutenberg.

  15. audunmb commented on Aug 5, 2022

    @audunmb

    Got directed here from the Wordpress forums because I asked for more options. Building the navigation block into a full megamenu block seems to be overkill. Megamenu blocks should be left to plugins, it's not something every website needs.

    Still, the Navigation block needs some more options. A footer menu where submenu items are shown (i.e. not a dropdown) like in the H&M example should be possible without a separate plugin. Not the only way to add a menu in FSE themes is the Navigation block, and you are forced to have a dropdown with it. An option to shown expanded can't be that hard to add.

    Also, there are a few UX downsides to using a hamburger menu, forcing it as the default responsive option is bad. A short menu for smaller screens, optionally with hamburger button for full menu (like in the much used Astra theme) is a much better option for most websites. Though, this is general responsivity issue, the best would be the options to have separately designed headers and footers for different screens (again like Astra does).

  16. paaljoachim commented on Sep 28, 2022

    @paaljoachim
    Contributor

    Here is an example from a site I am recreating with Twenty Twenty Two which has a lot of written material.
    The submenu feels very crammed.

    Screenshot 2022-09-28 at 16 37 30
    I assume I will need to use a bit of CSS to give the submenu more air.

  17. getdave commented on Oct 31, 2022

    @getdave
    Contributor

    Relaying some feedback from my YouTube channel:

    The Block Editor must natively allow the creation of Mega Menus for the Navigation Block

    It seems the demand for this feature is still strong.

  18. audunmb commented on Feb 1, 2023

    @audunmb

    A simple workaround for those who want a menu to display without the dropdown is to override the CSS. This forces the Navigation block to display (and show, not hide behind a dropdown) submenu items below the parent item without dropdown.
    This doesn't create a megamenu or anything, but it makes Navigation block useful for adding menus in the footer or other places where you don't want a dropdown.

    Not the most elegant solution, but it works (at least with TwentyTwentyTwo). If someone can make a more elegant CSS solution, please tell me.

    Add the class 'is-style-footer-menu' to the Navigation block (or create a block style for Footer Menu) and use this CSS:

    `.is-style-footer-menu .wp-block-navigation__submenu-container {
    color:inherit !important;
    border: none !important;
    background-color: initial !important;
    }

    .is-style-footer-menu ul.wp-block-navigation__submenu-container {
    visibility: visible !important;
    opacity: initial !important;
    position: static !important;
    width: auto !important;
    height: auto !important;
    min-width: 200px !important;
    }

    .is-style-footer-menu li.wp-block-navigation-item.has-child.wp-block-navigation-submenu{
    display: block !important;
    }`

  19. changed the title [-]Navigation block: Make nested menus fully customizable[/-] [+]Navigation block: Make nested menus fully customizable (Megamenus)[/+] on Feb 3, 2023
  20. added
    [Type] Enhancement
    and removed
    [Type] Enhancement
    on Jun 5, 2023
  21. annezazu commented on Mar 21, 2024

    @annezazu
    Contributor

    I wanted to follow up here to note that upcoming work in 6.5 helps folks get there. Here's a developer blog post on the topic: https://developer.wordpress.org/news/2024/02/29/an-introduction-to-block-based-mega-menus/

  22. paaljoachim commented on Dec 8, 2024

    @paaljoachim
    Contributor

    It would be very helpful with an update.
    Thanks!

  23. getdave commented on Dec 9, 2024

    @getdave
    Contributor

    My feeling is that it's highly unlikely that Core will provide a solution for this any time soon.

    Whilst we recognise the user need here, Navigation has other more fundamental issues that need to be addressed first.

    I'm currently working on reviewing all the Navigation Issues and relating them back to the Tracking Issue with a view to including Navigation work included in a future release.

    The focus must necessarily be on improving the basic interactions as a priority before we can begin to tackle these far more complex tasks.

  24. paaljoachim commented on Dec 9, 2024

    @paaljoachim
    Contributor

    Thank you for the update Dave @getdave

  25. added
    New Block
    on Aug 1, 2025
  26. paaljoachim commented on Aug 3, 2025

    @paaljoachim
    Contributor

    I see that Birgit mentioned various things about Mega menu here:
    https://gutenbergtimes.com/roadmap-for-wordpress-6-9-block-bindings-mega-menus-and-more-weekend-edition-336/

    It would be great to get some movement to make it easier for people to create mega menus directly in Gutenberg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs Design FeedbackNew Block[Block] Navigation[Type] Tracking Issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions