Skip to content

fix(theme): constrain navbar width to match main layout on wide displays#11782

Open
travisbreaks wants to merge 1 commit intofacebook:mainfrom
travisbreaks:fix/navbar-width-consistency
Open

fix(theme): constrain navbar width to match main layout on wide displays#11782
travisbreaks wants to merge 1 commit intofacebook:mainfrom
travisbreaks:fix/navbar-width-consistency

Conversation

@travisbreaks
Copy link

Summary

On wide screens (1400px+), the navbar stretches to the screen edges while the main content area and footer are constrained by --ifm-container-width. This creates a visual disconnect where navbar items sit far from the page content they relate to.

This PR adds two small CSS rules to constrain the navbar inner content:

  • .navbar gets justify-content: center so the inner content centers within the full-width navbar
  • .navbar__inner gets max-width: var(--ifm-container-width) and width: 100% to constrain its width while the navbar background still spans the full viewport

This matches the approach suggested in the issue and aligns with how Docusaurus v1 handled navbar width. The navbar background color/border still spans the full viewport width; only the inner content (logo, links, search) is constrained and centered.

Motivation

Closes #7562

Test plan

  • Verify navbar content is centered and constrained on wide screens (>1440px)
  • Verify navbar background still spans full viewport width
  • Verify no layout changes on screens <= 1140px (below container max-width)
  • Verify mobile navbar/sidebar is unaffected
  • Verify docs pages with sidebar still render correctly

Co-authored-by: Egger egger@horny-toad.com

🤖 Generated with Claude Code

On wide screens (>1400px+), the navbar stretches to the screen edges while
the main content area and footer are constrained by --ifm-container-width.
This adds max-width to .navbar__inner and centers it within the navbar,
so navbar items align with the rest of the page content. The navbar
background still spans the full viewport width.

Closes facebook#7562

Co-authored-by: Egger <egger@horny-toad.com>
@meta-cla
Copy link

meta-cla bot commented Mar 6, 2026

Hi @travisbreaks!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@netlify
Copy link

netlify bot commented Mar 6, 2026

[V2]

Built without sensitive environment variables

Name Link
🔨 Latest commit d826337
🔍 Latest deploy log https://app.netlify.com/projects/docusaurus-2/deploys/69aa4f700e8d6000089b2842
😎 Deploy Preview https://deploy-preview-11782--docusaurus-2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@meta-cla meta-cla bot added the CLA Signed Signed Facebook CLA label Mar 8, 2026
@slorber slorber added the Argos Add this label to run UI visual regression tests. See argos.yml GH action. label Mar 11, 2026
Copy link
Collaborator

@slorber slorber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please at least show a before screenshot showing the problem visually, and an after screenshot ?

This change is not in the ideal place, and is disruptive enough in terms of layout that we'll likely not want this to be in v3.x

with the rest of the page content.
See https://github.com/facebook/docusaurus/issues/7562
*/
:global(.navbar) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these global classes are usually defined in our css framework infima.dev

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

Labels

Argos Add this label to run UI visual regression tests. See argos.yml GH action. CLA Signed Signed Facebook CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Making navbar width consistent with the main layout on large displays

2 participants