next.js
fe0bb2fc - Next.js sticky scroll standards (#90197)

Commit
3 days ago
Next.js sticky scroll standards (#90197) <!-- Thanks for opening a PR! Your contribution is much appreciated. To make sure your PR is handled as smoothly as possible we request that you follow the checklist sections below. Choose the right checklist for the change(s) that you're making: ## For Contributors ### Improving Documentation - [x] Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - [x] Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # --> ### 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 `scroll` prop on `Link`. This documentation provides a web-standards solution using CSS `scroll-padding-top` to correctly position the scroll target. ### How? - Added a new "Handling sticky headers with `scroll-padding-top`" subsection to the `Link` component API reference (`docs/01-app/03-api-reference/02-components/link.mdx`) under the `scroll` prop. - Added a new "Scrolling with sticky headers" example to the "Linking and Navigating" guide (`docs/01-app/01-getting-started/04-linking-and-navigating.mdx`). --- [Slack Thread](https://vercel.slack.com/archives/C03KAR5DCKC/p1771434038077029?thread_ts=1771434038.077029&cid=C03KAR5DCKC) <p><a href="https://cursor.com/background-agent?bcId=bc-cc4b24d5-0e73-5b36-84a3-f40e65064f7c"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img alt="Open in Cursor" width="131" height="28" src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;<a href="https://cursor.com/agents?id=bc-cc4b24d5-0e73-5b36-84a3-f40e65064f7c"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/open-in-web-light.png"><img alt="Open in Web" width="114" height="28" src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a></p> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Joseph Chamochumbi <joseph.chamochumbi@vercel.com>
Author
Parents
Loading