Navbar
The Navbar component provides a persistent navigation bar with support for theming, authentication, and interaction tracking. It features a responsive design with a mobile menu and displays the total number of tracked interactions.Features
- Sticky positioning with backdrop blur effect
- Responsive design with hamburger menu for mobile
- Theme toggle (light/dark mode)
- Authentication integration showing user state and logout
- Interaction counter displaying total tracked interactions
- Active link highlighting based on current route
- Mobile menu with smooth animations
Usage
The Navbar is typically placed in the root layout and appears on all pages:Navigation Links
The Navbar includes the following navigation links (defined inNavbar.tsx:12-18):
| Link | Path | Icon | Description |
|---|---|---|---|
| Home | / | Home | Component showcase |
| Docs | /docs | FileText | Component documentation |
| Dashboard | /dashboard | BarChart3 | Analytics dashboard |
| Exports | /exports | Download | Data export page |
| Status | /status | Activity | System health check |
Dependencies
The Navbar component integrates with several contexts and stores:Theme Context
Interaction Context
Auth Store
Component Structure
Desktop Navigation
- Logo with link to home
- Navigation links with icons
- Interaction counter badge
- Theme toggle button
- Authentication section (login button or user info with logout)
Mobile Navigation
- Hamburger menu button
- Collapsible navigation menu
- Same links as desktop in a vertical layout
- Closes automatically on link click
Styling
The Navbar uses design tokens for consistent styling:- Sticky positioning (
sticky top-0 z-40) keeps navbar visible on scroll - Backdrop blur (
backdrop-blur-md) creates a frosted glass effect - Semi-transparent background (
bg-card/80) for depth - Border (
border-b border-border) separates from content - Transition animations on hover and active states
Active Link Highlighting
Active links are highlighted using Next.jsusePathname():
Mobile Menu
The mobile menu is controlled by state and includes animations:Icons
The Navbar uses icons fromlucide-react (imported at line 9):
Home- Home pageFileText- DocumentationBarChart3- DashboardDownload- ExportsActivity- StatusComponent- LogoMousePointerClick- Interaction counterMoon/Sun- Theme toggleMenu/X- Mobile menu toggle
Authentication Integration
The Navbar displays different UI based on authentication state:- Authenticated
- Not Authenticated
Shows user’s name and a logout button:
Accessibility
- Theme toggle has descriptive
aria-labelthat changes based on current theme - Mobile menu toggle has
aria-label="Toggle menu" - All interactive elements are keyboard accessible
- Active links are visually distinguished for screen readers
Best Practices
The Navbar should be rendered once at the root layout level, not on individual pages, to maintain consistent state across navigation.
Related Components
- Button - Used for login/logout actions
- Theme Context - Powers the theme toggle
- Authentication - Manages user state
Source Code
The complete Navbar implementation can be found atclient/app/components/Navbar.tsx:20-149.