Overview
The Header component provides a sticky navigation bar at the top of every page. It displays the site name, navigation links, and a theme toggle button. The header uses a backdrop blur effect and maintains accessibility across light and dark modes.Implementation
Location:src/components/Header.astro
The Header component is a standalone Astro component with no props. It reads configuration from PROFILE data and includes theme management scripts.
Key Features
- Sticky positioning with backdrop blur effect
- Responsive design with mobile-friendly spacing
- Theme persistence across page transitions
- Navigation links to Blog, Projects, Resume, and GitHub
- Brand link that navigates to homepage
Usage
The Header is imported and used in theBaseLayout component, making it available on all pages:
src/layouts/BaseLayout.astro
Configuration
The Header reads data from the profile configuration:src/content/profileData.ts
Customization
To customize the header:- Update navigation links - Edit the
<nav>section inHeader.astro - Change brand name - Modify
PROFILE.nameinprofileData.ts - Adjust styling - Update the Tailwind classes on the header elements
- Add/remove links - Add new
<a>tags following the existing pattern
Theme Toggle
The Header includes aModeToggle React component that allows users to switch between light and dark modes:
- Stored in
localStorage - Persisted across page transitions using
transition:persist - Applied via the
darkclass ondocumentElement
Styling
The header uses these key styles:sticky top-0 z-50- Keeps header visible while scrollingbg-background/95 backdrop-blur- Semi-transparent background with blurborder-b- Bottom border for visual separationsupports-[backdrop-filter]:bg-background/60- Enhanced transparency when backdrop-filter is supported
Scripts
The component includes inline scripts for theme management:Navigation Structure
Default navigation includes:- Resume - Links to PDF resume (
/Resume_Vaibhav_Sharma.pdf) - Blog - Links to posts listing (
/posts) - Projects - Links to projects page (
/projects) - GitHub - External link to GitHub repository
- Theme Toggle - React component for switching themes
Accessibility
- Uses semantic HTML with
<header>and<nav>elements - Proper link attributes (
target="_blank"withrel="noreferrer") - Maintains focus states with
focus:outline-noneandfocus:ringutilities - Works with keyboard navigation