From 0444ef09aa186a963e20586df67f07aa49614576 Mon Sep 17 00:00:00 2001 From: MOHAN Date: Thu, 2 Jul 2026 00:16:55 +0530 Subject: [PATCH] Fix navbar links not scrolling to sections react-router-dom's Link intercepts hash-only navigation for client-side routing and never triggers the browser's native scroll-to-anchor behavior. Also half the nav items (Use Cases, Docs, Security) pointed at section ids that were never built. Switched hash links to plain anchor tags (real same-page scrolling), added a real #contact target in the footer, and trimmed the nav/footer to only link sections that actually exist. Co-Authored-By: Claude Sonnet 5 --- src/components/landing/Navbar.tsx | 19 +++++++++++++------ src/index.css | 6 ++++++ src/pages/Landing.tsx | 16 +++++++++------- 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/components/landing/Navbar.tsx b/src/components/landing/Navbar.tsx index 5bdd115..81f636e 100644 --- a/src/components/landing/Navbar.tsx +++ b/src/components/landing/Navbar.tsx @@ -2,6 +2,13 @@ import { Link } from 'react-router-dom'; import { useState } from 'react'; import { Menu, X } from 'lucide-react'; +const SECTIONS = [ + { label: 'Features', hash: 'features' }, + { label: 'How It Works', hash: 'how-it-works' }, + { label: 'Pricing', hash: 'pricing' }, + { label: 'Contact', hash: 'contact' }, +]; + export default function Navbar() { const [open, setOpen] = useState(false); return ( @@ -18,9 +25,9 @@ export default function Navbar() { {/* Desktop nav */}
- {['Features', 'Use Cases', 'Pricing', 'Docs', 'Security', 'Contact'].map((item) => ( - {item} + {SECTIONS.map(({ label, hash }) => ( + {label} ))}
@@ -42,9 +49,9 @@ export default function Navbar() { {open && (
- {['Features', 'Use Cases', 'Pricing', 'Docs', 'Security', 'Contact'].map((item) => ( - setOpen(false)}>{item} + {SECTIONS.map(({ label, hash }) => ( + setOpen(false)}>{label} ))}
Log in diff --git a/src/index.css b/src/index.css index 9f1b022..c8107ec 100644 --- a/src/index.css +++ b/src/index.css @@ -2,6 +2,12 @@ @tailwind components; @tailwind utilities; +html { + scroll-behavior: smooth; + /* offset for the fixed navbar (h-16 = 4rem) so anchor targets aren't hidden underneath it */ + scroll-padding-top: 4rem; +} + @layer base { body { @apply bg-white text-gray-900 antialiased; diff --git a/src/pages/Landing.tsx b/src/pages/Landing.tsx index 98ce336..d1b8023 100644 --- a/src/pages/Landing.tsx +++ b/src/pages/Landing.tsx @@ -33,7 +33,7 @@ export default function Landing() { {/* Footer */} -