question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Menu in Header has wrong height

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Reproduction link

Edit on CodeSandbox

Steps to reproduce

Use <Menu /> in <Layout.Header /> component to create basic header navbar

What is expected?

Ant components that are commonly used together should be working together nicely out of the box

What is actually happening?

When you use <Menu /> in <Layout.Header />, it does’t work out of the box. Menu has lower height that Header thus its not vertically aligned

Environment Info
antd 3.13.1
React 16.7
System MacOS
Browser Chrome

Easiest solution would be to write custom menu styles in the layout styles. However from what I have seen, you dont mix styles between components like this.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:3
  • Comments:9 (8 by maintainers)

github_iconTop GitHub Comments

14reactions
Duder-onomycommented, Feb 11, 2021

This should be fixed. It is a terrible ‘first experience’ for this framework. One of the first things I do when building a website is put together the header and nav. Putting a <Menu in the <Layout.Header is one of the very first things most people will do (IMO).

When it does not work correctly, the first time, people will think the whole framework is busted and nothing works well together. It will sour their opinion of how this framework was built. God forbid they actually find this github issue and think that adding a style={{ lineHeight into their code is a good idea at all. In fact, I believe people using AntD are trying NOT to customize and put hard coded styling into their application at all. This will decouple the ‘header’ from the theme, which removes any ability to easily change the header height later. Changing this @layout-header-height will no longer properly change the header height.

Look at this issue here: https://github.com/ant-design/ant-design/issues/15744 ^ The person abandoned the framework after realizing they could not even put a NavBar together without customizing styles directly on the component level.

I think AntD should:

  • Fix this issue how @Kamahl19 suggests. Ensure the menu assumes the line-height from the @layout-header-height variable when rendered within a Layout.Header. OR
  • Add a legitimate NavBar component to the library so people can get around this issue.
5reactions
ztplzcommented, Feb 7, 2019

I see. Since you don’t want to set the style in the Header, you can set the style in menu.item. image

Read more comments on GitHub >

github_iconTop Results From Across the Web

Menu and Header height gone wrong - Support | Kriesi.at - Premium ...
Hello,. I have just noticed an issue with my home page menu on IE and in all browsers when screen width is between...
Read more >
Vertically center menu within variable height header
I have a header that may or may not contain an image/logo and whose size is variable. I'd like to vertically align my...
Read more >
Header height overflowing with widget - WordPress.org
I had tried every setting, once I change In the header Primary Menu option widget to other none or search. The header height...
Read more >
menu item height - changes mobile header height
If I set the – menu item height – so the menu is OK then the header is too small and if I...
Read more >
How to reduce the height of the Secondary Header Bar to only ...
1. Please send your website url so that we can provide a possible css for the secondary header height. 2. Please head to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found