Draft
Conversation
Document how to use the CSS scroll-padding-top property to handle sticky/fixed headers with Next.js auto-scroll behavior on navigation. Next.js skips sticky and fixed positioned elements when scrolling to new content during client-side navigation. This can cause content to appear behind a sticky header. The scroll-padding-top CSS property on the scroll container (html) offsets scroll positioning to account for the sticky element's height. Added to: - Link component API reference (scroll prop section) - Linking and Navigating getting started page (examples section) Co-authored-by: Jimmy Lai <hello@jimmyl.ai>
|
Cursor Agent can help with this pull request. Just |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Adds documentation for handling sticky headers with Next.js navigation using
scroll-padding-top.Why?
Next.js's auto-scroll behavior explicitly skips sticky and fixed positioned elements. This can cause content to appear behind sticky headers when navigating to a hash fragment or using the
scrollprop onLink. This documentation provides a web-standards solution using CSSscroll-padding-topto correctly position the scroll target.How?
scroll-padding-top" subsection to theLinkcomponent API reference (docs/01-app/03-api-reference/02-components/link.mdx) under thescrollprop.docs/01-app/01-getting-started/04-linking-and-navigating.mdx).Slack Thread