Skip to content

docs(nav): pill header docks flush to the viewport top on scroll - #184

Merged
soamdesai-tfh merged 1 commit into
mainfrom
soam/docs-header-scroll-17343e
Sep 16, 2026
Merged

soamdesai-tfh merged 1 commit into
mainfrom
soam/docs-header-scroll-17343e

Conversation

@soamdesai-tfh

Copy link
Copy Markdown
Contributor

Summary

On desktop (≥1440px) the floating pill header kept a 24px gap above it while scrolling. The pill now rides up with the page and docks flush against the top of the viewport once the page has scrolled 24px. At rest the header is unchanged.

Why the gap existed

The 24px offset was a top margin on the pill inside the sticky #navbar. A sticky element never scrolls, so its inner margin never scrolled away either.

How it is fixed (pure CSS)

  • The offset moves onto the sticky #navbar itself. A sticky box docks by its border edge, so the margin scrolls away with the page: 24px gap at rest, 0 once scrolled ≥24px.
  • #navbar cannot query its own width, so its parent (which it fills edge to edge) becomes the query container for that one rule via div:has(> #navbar) { container-type: inline-size }. Both cross 1440px together, so docking follows the pill exactly, including when the hosted assistant panel narrows the page.
  • No JS and no scroll listener. Scroll-driven animations were ruled out (no Firefox support), and Mintlify toggles nothing in the DOM on scroll, so CSS had no other hook.

Verified locally with mint dev

Scrolled Pill top edge
0px 24px
12px 12px
≥24px, including page bottom 0px
  • Docs page and the custom-mode homepage, light and dark.
  • Two-row layout below 1440px untouched (navbar margin stays 0, backdrop still shown).
  • Mintlify recomputes --scroll-mt from the navbar height (148px → 124px), so anchored headings keep their 40px clearance below the docked header.

Design note

The pill keeps its rounded corners and hairline border when docked. Squaring the top corners in the docked state would need a small script, since CSS has no hook for the "stuck" state. Happy to follow up if design wants that.

The floating pill kept its 24px gap above it while scrolling because the
offset lived inside the sticky #navbar. Move the offset onto #navbar
itself: a sticky box docks by its border edge, so the margin scrolls
away with the page and the pill sits flush against the top of the
viewport once the page has scrolled 24px. At rest nothing changes.

#navbar cannot query its own width, so its parent (which it fills edge
to edge) becomes the query container for that one rule. The two-row
layout below 1440px is untouched, and Mintlify derives --scroll-mt from
the 84px navbar height, so anchored headings keep their clearance.
@mintlify

mintlify Bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated
world 🟢 Ready View Preview Sep 16, 2026, 6:31 PM

💡 Tip: Enable Automations to automatically generate PRs for you.

@Takaros999 Takaros999 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved: focused CSS-only navbar docking fix; current checks are green.

@soamdesai-tfh
soamdesai-tfh merged commit 3071016 into main Sep 16, 2026
9 checks passed
@soamdesai-tfh
soamdesai-tfh deleted the soam/docs-header-scroll-17343e branch September 16, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants