Improve theme.json support for Navigation block
What problem does this address?
There are many settings available to the navigation block which cannot be customized in theme.json. It is beneficial to themes to be able to style blocks via theme.json rather than in block settings, as it means themes can share patterns and simply modify the navigation via theme.json, rather than each theme needing to create its own header to adjust the navigation.
What is your proposed solution?
It is already possible to set colors and typography for the navigation block in theme.json, but the following properties would also be helpful:
- [ ] Gap
- [ ] Submenu color and background
- [ ] Overlay background
- [ ] Borders
- [ ] Navigation link states (hover, active, focus) (context)
- [ ] Hiding more than N items (context)
- [x] Behaviour of dropdowns (context)
This is list is a good starting point but we should anticipate other properties also being needed.
cc @getdave @draganescu
Excellent list, thank you! I would also add: overlay menu padding that potentially inherits from a smarter global padding (#35607), but is still individually configurable.
One consideration to keep in mind for the overlay menu properties is in case it becomes possible to edit the contents separately for total customization.
Worthing adding to https://github.com/WordPress/gutenberg/issues/38275 ?
Worthing adding to https://github.com/WordPress/gutenberg/issues/38275 ?
Yes please!
May I add here that currently the theme.json block settings for colors on the nav block are unresponsive. I would be nice if this works too!
{
"settings": {
"blocks": {
"core/navigation": {
"color": {
"text": false,
"background": false
}
}
}
}
}
What would you expect false to do in this context?
What would you expect
falseto do in this context?
To disable the color controls for the user in the block editor for this specific block.
Specifically, for theme authors who do not want to give color controls to users (clients) on the menu blocks.
It was my assumption that this table theme.json v2 - living reference will be applicable for all blocks (eventually).

It was my assumption that this table theme.json v2 - living reference will be applicable for all blocks (eventually).
I believe this is a correct assumption :)
We also should have a way to target the typography inside the overlay: https://github.com/WordPress/gutenberg/issues/39352
I am starting to wonder if the overlay should be a separate block...
I had some issues with the .has-background class that were coupled with the color styling of submenu background. It is a tad weird and confusing. Would give another possible argument for splitting these two (submenu and menu overlay)
Since I've been working this week on testing the menu block in my own starter theme, I've come upon some other 'theme.json for navigation' related here: #39263 , maybe relevant to your list.
I am starting to wonder if the overlay should be a separate block...
Would that enable or simplify this?
I am starting to wonder if the overlay should be a separate block...
It should. I've been thinking about it as well.
It looks like the https://github.com/WordPress/gutenberg/pull/37543
The block does have support for blockGap, but it doesn't work in theme.json, see https://github.com/WordPress/gutenberg/issues/39789
Was about to write an issue for the states when I saw this one! Would be great to have hover, active and visited states on these as they're links. Should be copy/paste-able from the link block. :)
Related https://github.com/WordPress/gutenberg/issues/44712
We also can not do this to style navigation, this is much needed
"styles": {
"blocks": {
"core/navigation": {
"elements": {
"link": {
"color": {
"text": "red"
},
":hover": {
"color": {
"text": "blue"
}
}
}
}
}
}
}
We also can not do this to style navigation, this is much needed
"styles": { "blocks": { "core/navigation": { "elements": { "link": { "color": { "text": "red" }, ":hover": { "color": { "text": "blue" } } } } } } }
I found this isn't due to lack of support, but instead a bug where there is a "color: inherit" class that takes precedence... it's in a bug ticket somewhere here. In the meantime you can make it work by using !important:
"styles": {
"blocks": {
"core/navigation": {
"elements": {
"link": {
":hover": {
"color": {
"text": "#8B6212 !important"
}
}
}
}
}
}
}```
Thanks everyone for this list. Most of it has landed: block gap in theme.json, interactive state styling (#76491), hiding extra items (#27131), and a fully customizable overlay via the navigation-overlay template part. Submenu colours are tracked in #44712. Closing this tracker.