원클릭으로
smooth-scroll
Add smooth scrolling for same-page anchor links only. Uses JavaScript to handle
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Add smooth scrolling for same-page anchor links only. Uses JavaScript to handle
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Build pages by installing shadcnblocks sections and implementing i18n. Use for each page after branding is defined. Takes page route and list of sections to install. Installs sections in order, creates page file, extracts text to de.json/en.json, and adds useTranslations.
Add cinematic lerp-based smooth scrolling for all scroll inputs (mouse wheel, trackpad, touch). Creates butter-smooth momentum scrolling like premium agency websites. Works alongside existing smooth-scroll anchor links.
Define brand styling for website projects. Updates globals.css with CSS color variables (oklch format), typography (h1-h6, p, a, blockquote), and container styles. Use at the start of a project after sitemap is created. Requires primary, secondary, and accent colors plus font choice.
Add elegant page transition overlay using 3 staggered color layers. Overlay covers screen during navigation and reveals once new page is loaded. Use during /init or standalone.
Configure footer navigation links for SEO completeness. Sets up all pages (Homepage, Services, About, Contact, Impressum, Datenschutz) in organized groups. Dynamically finds footer*.tsx component. Updates i18n with all footer keys.
Configure navbar menu items, logo, buttons, and styling. Sets up navigation from sitemap.md, ensures dropdown z-index is above content, configures buttons, and updates i18n. Dynamically finds navbar*.tsx component.
| name | smooth-scroll |
| description | Add smooth scrolling for same-page anchor links only. Uses JavaScript to handle |
Enable smooth scrolling for same-page anchor links only. Page navigations always start at the top instantly.
CSS scroll-behavior: smooth affects ALL scrolling, including Next.js page navigations. This causes unwanted smooth scrolling when changing pages.
Our approach: Use JavaScript to handle only #anchor link clicks with smooth scroll. Page navigations use browser default (instant to top).
scroll-padding-top, remove scroll-behaviorCreate website/components/ui/smooth-scroll.tsx:
"use client";
import { useEffect } from "react";
export function SmoothScroll() {
useEffect(() => {
// Check for reduced motion preference
const prefersReducedMotion = window.matchMedia(
"(prefers-reduced-motion: reduce)"
).matches;
const handleClick = (e: MouseEvent) => {
const target = e.target as HTMLElement;
const anchor = target.closest('a[href^="#"]');
if (anchor) {
const href = anchor.getAttribute("href");
if (href && href.startsWith("#") && href.length > 1) {
const element = document.querySelector(href);
if (element) {
e.preventDefault();
element.scrollIntoView({
behavior: prefersReducedMotion ? "auto" : "smooth",
});
}
}
}
};
document.addEventListener("click", handleClick);
return () => document.removeEventListener("click", handleClick);
}, []);
return null;
}
Add SmoothScroll to app/[locale]/layout.tsx:
import { SmoothScroll } from "@/components/ui/smooth-scroll";
export default function LocaleLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<>
<SmoothScroll />
{/* rest of layout */}
</>
);
}
Ensure globals.css has scroll-padding but NOT scroll-behavior:
@layer base {
html {
/* Smooth scroll handled by JS for anchor links only */
scroll-padding-top: 5rem; /* Offset for fixed navbar */
}
}
DO NOT add scroll-behavior: smooth - this causes page navigation issues.
For links that scroll to sections on the same page, use the # anchor format:
// In navbar or any component
<Link href="#pricing">Pricing</Link>
<Link href="#faq">FAQ</Link>
<Link href="#contact">Contact</Link>
// Target sections need matching IDs
<section id="pricing">...</section>
<section id="faq">...</section>
<section id="contact">...</section>
Each section that should be a scroll target needs an id attribute:
// Before
<section className="py-16 lg:py-24">
// After
<section id="features" className="py-16 lg:py-24">
| Section | ID |
|---|---|
| Hero | hero |
| Features | features |
| Pricing | pricing |
| FAQ | faq |
| Contact | contact |
| About | about |
| Portfolio/Projects | projects |
| Testimonials | testimonials |
The scroll-padding-top in globals.css handles the offset:
html {
scroll-padding-top: 5rem; /* Adjust based on navbar height */
}
This is respected by scrollIntoView().
| Action | Scroll Behavior |
|---|---|
Click #anchor link | Smooth scroll to section |
| Navigate to new page | Instant to top (no animation) |
| Browser back/forward | Browser default |
| Reduced motion user | Instant scroll |
SmoothScroll component created at components/ui/smooth-scroll.tsxapp/[locale]/layout.tsxscroll-padding-top set in globals.cssscroll-behavior: smooth in globals.css#anchor link scrolls smoothlyAfter running this skill:
components/ui/smooth-scroll.tsx - Anchor link handlerapp/[locale]/layout.tsx - Updated with SmoothScrollglobals.css - Only scroll-padding-top, no scroll-behavior