Skip to content

feat: add top and bottom sticky mobile navigation#1780

Merged
Rich-Harris merged 4 commits intomainfrom
feat/mobile-nav-sticky-headings
Feb 22, 2026
Merged

feat: add top and bottom sticky mobile navigation#1780
Rich-Harris merged 4 commits intomainfrom
feat/mobile-nav-sticky-headings

Conversation

@theetrain
Copy link
Contributor

@theetrain theetrain commented Feb 9, 2026

Changes

Svelte.Sticky.Mobile.Nav.Headers.mov

This was motivated by it being challenging for me to discover and navigate to CLI or MCP docs that are far down the navigation container.

Tested on:

  • Chrome
  • Firefox
  • Safari

Test scenarios:

  • Short viewport height, iPhone 13 and Pixel 7 portrait and landscape dimensions, 200% browser font size

Some notes:

  • <section> elements were removed since they didn't seem to add more value than the nav headings themselves. Without aria-labelledby, the <section> elements didn't seem to serve much purpose; and with them gone, it's now possible to make section headings sticky on the top and bottom. I'll verify this later to make doubly sure since I'm running with the assumption that screen readers may navigate by headings sufficiently within the <nav> landmark.

Some todos:

  • Add a vertical viewport media query to stack headings only when there's enough space; otherwise use a disclosure widget and collapse grouped headings as they sit on the top or bottom depending on the nav menu's scroll position.
  • Consider denser grouping while headings are stacked.
  • Consider special styling for headings while they are sticky, though we may be blocked from a CSS-only solution due to container queries yet being able to target elements that are stuck: https://caniuse.com/mdn-css_at-rules_container_scroll-state_queries.
  • Test with various zoom levels and browser font sizes.

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time.
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.

@vercel
Copy link

vercel bot commented Feb 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
svelte-dev Ready Ready Preview Feb 12, 2026 4:08am

Request Review

@theetrain theetrain force-pushed the feat/mobile-nav-sticky-headings branch from 79cefa7 to d6fb3f0 Compare February 10, 2026 02:41
@theetrain theetrain marked this pull request as ready for review February 10, 2026 02:44
height: 4.8rem;
padding: 0 var(--sk-page-padding-side);
z-index: 2;
z-index: 10;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was necessary to prevent headings from covering the 'back to docs' button.

@theetrain
Copy link
Contributor Author

theetrain commented Feb 10, 2026

Taking this back to improve appearance on most phones since I didn't account for the iOS Safari URL bar:

  • Change container query to height < 450px
  • Make space between stacked headings denser
  • Try adding a shadow to indicate there is more content to scroll into
image

- Add top and bottom sticky nav headings in mobile nav
- And make sticky header experience visible when nav area is 450 pixels tall or greater
- Style menu list items to include a left space and vertical border to differentiate itself from headings and subtly indicate scrollability.
@theetrain theetrain force-pushed the feat/mobile-nav-sticky-headings branch from 04d8a17 to 5a90723 Compare February 12, 2026 03:47
@theetrain theetrain marked this pull request as ready for review February 12, 2026 03:47
Copy link
Member

@Rich-Harris Rich-Harris left a comment

Choose a reason for hiding this comment

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

super cool!

@Rich-Harris Rich-Harris merged commit fa6c0fa into main Feb 22, 2026
2 checks passed
@Rich-Harris Rich-Harris deleted the feat/mobile-nav-sticky-headings branch February 22, 2026 20:34
@teemingc teemingc linked an issue Feb 24, 2026 that may be closed by this pull request
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.

Mobile menu on homepage is confusing

2 participants