Skip to content

Ability to customise Navigation block "mobile" overlay  #39142

Closed
2 of 2 issues completed
Closed

Description

@getdave

What problem does this address?

Currently any styles you apply to the Navigation block will also apply when it is in "mobile" mode. This is sometimes not desirable as the "mobile" menu may require different visual properties.

Furthermore, it may also be desirable to add additional content (other than simply the Navigation block) to the overlay.

Example of styling inconsistencies

For example, if you align the navigation items to the right then the items in the mobile menu are also right aligned.

Screen.Capture.on.2022-03-01.at.16-35-20.mov

What is your proposed solution?

The solution may be to allow the overlay to be defined as a template part. A user could create the appropriate template part (e.g. navigation-overlay.html) and then the block would allow the user to "assign" the template part to the block to be used as the overlay.

As template parts are containers this would provide freedom to style the overlay as required as well as to add any content required.

We could explore adding dedicated UI controls which only apply to the navigation when it is in mobile mode. That said, it might get complex if styles are not mutually exclusive so the mobile styles would have to take precedence.

Alternatively we could wait for a more robust responsive styling solution to land in Gutenberg which might allow blocks to define a standard means to style elements different based on viewport.

Related

#43852

Activity

  1. added
    CSS StylingRelated to editor and front end styles, CSS-specific issues.
    on Mar 1, 2022
  2. jasmussen commented on Mar 2, 2022

    @jasmussen
    Contributor

    It's good to have a dedicated issue for this one, thank you, I definitely agree.

    I touched a bit on the following concept in this comment as well, but the way I see it, the contents of your mobile overlay is a blank canvas, and you should be able to put any block there, including columns and non navigation blocks.

    One idea here is to leverage the same concept of saving inner blocks to a custom post type, as the navigation block does for its menu items. That is, have an entirely separate CPT for the contents of the modal. Here's an early mockup:

    Editing navigation in isolation

    One subgoal to accomplish here would be to ensure that the X to close the modal could sit exactly where the = menu item sits, so it feels like the same button. A root level padding solution (#35607) that is inherited by the modal (but user overridable) would be a good start for that.

    Another idea that might help is, if the navigation block is used inside a Header template part, the entire template part is kept (duplicated) inside the modal overlay, with logo and open/close button. 
This would also let the burger icon transform into a close icon, which could be a nice touch.

  3. getdave commented on Mar 2, 2022

    @getdave
    ContributorAuthor

    Thanks for your excellent insight as always @jasmussen.

    ...the contents of your mobile overlay is a blank canvas, and you should be able to put any block there, including columns and non navigation blocks.

    I think the idea of a wrapper into which you can place multiple Navigation blocks is a good idea. After all if the menus are drastically different them they shouldn't be the same <nav> anyway.

    From a technical POV that's a challenge because it's going to require a separate "mobile overlay" block which has the ability to be populated differently in the editor canvas depending on the value of an inspector control toggle.

    As a user I need to be able to switch between populating the "desktop" and "mobile" variations of the block. I have a video which explains how you can use x2 separate Navigation blocks and use CSS to show and hide them. It would be similar to this concept, except we'd need a design/UX solution for how users would interact with the block within the editor - that's the big challenge. How would you see that working?

  4. jasmussen commented on Mar 2, 2022

    @jasmussen
    Contributor

    It would be similar to this concept, except we'd need a design/UX solution for how users would interact with the block within the editor - that's the big challenge. How would you see that working?

    Yes, that's definitely similar.

    My instinct is always to start with as little as possible, the shortcomings always have a way of presenting themselves when you do that, so you can address them one by one.

    In this case, I would lean towards the mockup above: if you toggle the mobile menu to "always" and click the burger icon in the canvas, the very act of clicking that item would open up the modal with a new blank canvas, with any saving or creation of a dedicated overlay slot happening transparently in the background.

    Some questions immediately present themselves:

    • Should we copy the navigation block you built before toggling "Always" into the overlay? Perhaps yes.
    • Should you be able to have a dedicated overlay also when the "Mobile" option is toggled? Maybe, but could also wait?
    • Is it enough to click the burger icon in the canvas to load the contents of the overlay in template isolation mode? Or should there also be a dedicated button in the inspector, "Edit overlay"?
    • Do I need to be able to swap out the contents of one overlay with another if one such exists, just like the nav block itself? Sure maybe.

    All of those feel solvable, even if it is legitimately a big and challenging project. From an UX perspective, the biggest challenge I see with the approach is how this is compatible with editing the contents of the navigation block in isolation (i.e. #37950) since the UI may end up being very similar. My hope is that in practice it'll be fine: when it's collapsed to a burger button, it loads the overlay, when it's not, it loads the innerblocks of the parent nav instead.

  5. scruffian commented on Mar 10, 2022

    @scruffian
    Contributor

    We'd like to be able to style the overlay differently to the regular block, using theme.json. Unless we create a lot of extra properties in theme.json for the Navigation block, we're going to find it difficult to support all these different properties. However what if we made the overlay its own block? Then we can simply use the standard theme.json properties on that block...

  6. jasmussen commented on Mar 11, 2022

    @jasmussen
    Contributor

    You suggested here that the overlay could be a block. Here we are discussing something adjacent, total customization of the contents of an overlay. In both cases we'd need theme.json integration — are the two tasks complementary?

  7. scruffian commented on Mar 11, 2022

    @scruffian
    Contributor

    Yeah I think they are basically the same thing!

  8. getdave commented on Mar 15, 2022

    @getdave
    ContributorAuthor

    I've been thinking about this as well and come to the same idea.

    We could have some kind of wrapping block that allows you to toggle when the overlay is displayed (like the Nav block does today).

    Then you could nest Nav blocks within that block. It could provide context to customise the behaviour.

  9. luisherranz commented on May 3, 2022

    @luisherranz
    Member

    I think this could be elegantly solved without any ad-hoc implementation if:

    1. We add the ability to configure different layers/states using blocks.

    2. We allow any block to become a section capable of overwriting the global styles of their children.

  10. phil-sola commented on Mar 31, 2023

    @phil-sola

    This definitely needs reviving - the mobile menu is horrible out of the box and for a non-developer who may not know how to write CSS to style it any differently, that could be pretty offputting. I love the initial mockup and thought process from @jasmussen regarding a blank canvas to build out the overlay using blocks including columns, buttons, navigations.

    Some really fantastic mobile overlay designs could be created directly in the block editor for everyone without needing to be a skilled developer to hack away at the current implementation.

  11. getdave commented on Mar 31, 2023

    @getdave
    ContributorAuthor
  12. changed the title [-]Style Navigation block differently for "mobile menu"[/-] [+]Ability to customise Navigation block "mobile" overlay [/+] on Nov 19, 2024
  13. getdave commented on Nov 19, 2024

    @getdave
    ContributorAuthor

    In light of developments in #43852 I've rewritten the title and description of this Issue to better reflect the objective and to provide a canonical Issue for folks to refer to.

  14. 1 remaining item

  15. mikemcalister commented on Oct 9, 2025

    @mikemcalister

    Hey folks, there has been some discussion about looking at Ollie's Menu Designer as a possible solution for this. The repo is open and right now the plugin is available on WP.org.

    I'm totally open for this to be considered for core (or whatever parts make sense), but right now I don't have the bandwidth to shepherd it through myself. I'm happy to advise and help guide it along though. Just let me know what you need from me.

  16. annezazu commented on Oct 9, 2025

    @annezazu
    Contributor

    Hey @mikemcalister! Thanks so much for both confirming this publicly here and for being game for this in general. It's really awesome to see when this has been a long standing point of feedback. Let's get some devs to review what you have in place, determine what might conflict and what might be compatible, and go from there. I imagine we'll need design help as this gets underway further in the future so a light flag for @jasmussen (nothing is needed right now).

  17. jasmussen commented on Oct 10, 2025

    @jasmussen
    Contributor

    Thanks for the light flag on the exciting potential. I'm here to help if/when things connect.

  18. karmatosed commented on Oct 10, 2025

    @karmatosed
    Member

    I am super excited to see this @mikemcalister and even more so to see momentum after you posted. Can’t wait to see something brew up.

  19. mikemcalister commented on Oct 12, 2025

    @mikemcalister

    I'm not sure if this is the best place for this, but we should get some kind of clarity on what we're hoping to implement from Menu Designer. It does mobile and mega menus. This discussion is around the mobile menu part.

    The mega menus are quite a bit more complex because of the settings and adjustments needed to make them display accessibly and predictably across all themes. It's more complex than it might seem.

    So it would be helpful to understand what we're aiming for.

  20. mikemcalister commented on Oct 16, 2025

    @mikemcalister

    Something that would be super helpful for user/dev experience is to keep the Menu template part slug/name so users could easily transition to the core solution once implemented. Between Nick Diego's prototype and Menu Designer, that would be potentially thousands of users that could seamlessly transition.

  21. getdave commented on Oct 17, 2025

    @getdave
    ContributorAuthor

    Hi @mikemcalister. Thanks for your input here (and for the Plugin!).

    We're just wrapping up a few things for the 6.9 cycle right now but myself and @scruffian are intending to propose a route forward here so that we can gain alignment.

    Please do deep an eye on the Issue. We'd value your feedback.

  22. scruffian commented on Oct 17, 2025

    @scruffian
    Contributor

    Something that would be super helpful for user/dev experience is to keep the Menu template part slug/name so users could easily transition to the core solution once implemented. Between Nick Diego's prototype and Menu Designer, that would be potentially thousands of users that could seamlessly transition.

    I think that your plugin uses the a slug of mobile for overlay template parts. I think this name is a bit misleading, since it is possible to set the overlay to always appear - not just on mobile. For that reason I think it's more likely that we'll go with a more generic name like overlay. I know this means that template parts will not work, but I don't think we can justify using a name that doesn't quite fit. I'm open to other opinions though :)

  23. scruffian commented on Oct 17, 2025

    @scruffian
    Contributor

    @mikemcalister thanks for all the work on the Ollie Menu Designer. It's great how well it reuses parts of core that are already there - leaning into template parts and patterns. This has really helped validate that the approach we were exploring in #55657 is the right one, and that this is a feature that users really want.

    There were some great additions in the plugin too - the Preview button is super helpful, and all of the patterns that come with the theme really help support the overlay, so it all works really nicely together.

    The plugin has also helped us to realise that we are still missing an important feature in core to support this - template part persistence. At the moment when switching themes you lose access to your template parts from previous themes. We need to address this as part of this work, so that overlays can persist across theme switches.

    I'm also curious to hear your experience of building this plugin - was there anything you had to work around or which you think could be improved in core to make this easier?

    Thanks again for all you work :)

  24. annezazu commented on Oct 17, 2025

    @annezazu
    Contributor

    The plugin has also helped us to realise that we are still missing an important feature in core to support this - template part persistence. At the moment when switching themes you lose access to your template parts from previous themes. We need to address this as part of this work, so that overlays can persist across theme switches.

    Ensuring this is tracked here: #72452

  25. mikemcalister commented on Oct 20, 2025

    @mikemcalister

    I think that your plugin uses the a slug of mobile for overlay template parts.

    Hey @scruffian, the template part area I'm referring to uses simply menu to register the area, it's not specific to mobile.

    function omd_template_part_areas( array $areas ) {
    	$areas[] = array(
    		'area'        => 'menu',
    		'area_tag'    => 'div',
    		'description' => __( 'Menu templates are used to create dropdown menus and mobile menus.', 'ollie-menu-designer' ),
    		'icon'        => 'layout',
    		'label'       => __( 'Menu', 'ollie-menu-designer' ),
    	);
    
    	return $areas;
    }
    

    was there anything you had to work around or which you think could be improved in core to make this easier?

    We let users create a new template part (and edit one) inline with some links below the selector. This helps bridge the gap between the template part screen and the editor screen. However, we have to open this in a new tab and it kind of breaks the flow. Ideally, this could be handled with the navigator just like we do when we edit template parts from within the editor, so users can easily navigate into an edit screen and then back out.

    Image

    We also let them customize the mobile menu toggle background and color. That wasn't particularly tricky, per se, but could be done much cleaner with a core implementation.

    That's all I can think of off the top of my head for workarounds. Ultimately, the mobile part of this isn't very complicated because it's largely using technology we already have. The mega menu part on the other hand... 😅

  26. scruffian commented on Oct 20, 2025

    @scruffian
    Contributor

    the template part area I'm referring to uses simply menu to register the area, it's not specific to mobile.

    Ah yes, that may be more reusable. We usually go with "navigation" rather than "menu" because of the potential confusion with restaurants...

  27. getdave commented on Jul 20, 2026

    @getdave
    ContributorAuthor

    I consider this completed as of WordPress 7.0.

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

    CSS StylingRelated to editor and front end styles, CSS-specific issues.[Block] NavigationAffects the Navigation Block[Type] EnhancementA suggestion for improvement.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions