--- name: mobile-bottom-navbar description: Standardized mobile bottom navigation implementation for internal Next.js applications. Provides role-based filtering, smooth animations, persistent state, and submenu expansion with accordion-based More menu. Supports Next.js 15+ with App Router, TypeScript, Zustand state management, and Framer Motion animations. Includes complete ready-to-use components with icon grid layouts, comprehensive documentation, and customization guides. triggers: - mobile nav - bottom navbar - mobile navigation - add mobile nav - create bottom bar - mobile bottom navigation - bottom navigation bar - mobile menu --- # Mobile Bottom Navbar ## Overview This skill provides a complete, production-ready mobile bottom navigation system for Next.js 15+ applications with App Router. The implementation features: - **3-Column Icon Grid Layouts** for submenus and More menu - **Accordion-Based More Menu** with collapsible group sections - **Submenu Dropdown** appearing above the navbar - Role-based filtering and smooth animations **πŸ“Έ Visual Reference:** See `references/screenshots/` for actual UI examples from MyJKKN application. ### Key Features - **Icon Grid Submenus**: 3-column grid layout with icons + labels (like iOS app grid) - **Accordion More Menu**: Collapsible sections showing all overflow menu groups - **Always Visible Design**: Full navbar always shown on mobile (no separate minimized state) - **Role-Based Filtering**: Dynamic navigation based on user permissions - **Smart Active Detection**: Automatically highlights current page - **Submenu Expansion**: Click nav items to expand submenus with backdrop overlay - **Overflow Handling**: "More" menu for navigation groups beyond primary 4 items - **State Persistence**: Zustand with localStorage for cross-session state - **Hydration Safety**: Prevents flash of incorrect state on page load - **Smooth Animations**: Spring-based animations via Framer Motion - **iOS Safe Area Support**: Respects notch and home indicator spacing - **TypeScript First**: Fully typed for excellent DX - **Customizable**: Colors, animations, layouts, and icons ### UI Pattern (Critical Design Elements) #### βœ… Bottom Navbar ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ [Icon] [Icon] [Icon] [Icon] [Icon] β”‚ β”‚ Overview User Mgmt Apps App Hub More (5+) β”‚ β”‚ ─ β”‚ ← Active indicator β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` - 4 primary items + "More" button with badge count - Even spacing, icons with labels below - Active state: primary color + underline indicator #### βœ… Submenu Dropdown (Opens ABOVE navbar) ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ πŸ“Š β”‚ β”‚ πŸ€– β”‚ β”‚ β”‚ β”‚ ← 3-column grid β”‚ β”‚Dash β”‚ β”‚ AI β”‚ β”‚ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ← Navbar (below) ``` - Grid layout (3 columns) - Icon + label cards - Appears above navbar with backdrop #### βœ… More Menu Modal (Accordion with Icon Grid) ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ All Menus βœ• β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ > Organization Management 9 β–Ό β”‚ ← Accordion header with count β”‚ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ 🏒 β”‚ β”‚ πŸŽ“ β”‚ β”‚ πŸ”₯ β”‚ β”‚ ← 3-column icon grid β”‚ β”‚Inst β”‚ β”‚Degr β”‚ β”‚Dept β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ πŸ“š β”‚ β”‚ πŸ“… β”‚ β”‚ πŸ“– β”‚ β”‚ β”‚ β”‚Prog β”‚ β”‚Seme β”‚ β”‚Sect β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β” β”‚ β”‚ β”‚ πŸ“ β”‚ β”‚ πŸ—ΊοΈ β”‚ β”‚ β”‚ β”‚ β”‚ β”‚Cour β”‚ β”‚Maps β”‚ β”‚ β”‚ β”‚ β”‚ β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”˜ β”‚ β”‚ β”‚ β”‚ > Finance Management 6 β–Ά β”‚ ← Collapsed section β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` **Critical Pattern Elements:** 1. **Sheet Component**: Bottom sheet with rounded top (`rounded-t-3xl`) 2. **Accordion**: `type="multiple"` with all groups expanded by default 3. **Group Headers**: Icon badge + label + count + chevron 4. **Submenu Grid**: 3-column layout with icons and labels 5. **Active Highlighting**: Primary color ring and background ### When to Use This Skill Use this skill when: - Implementing mobile navigation for Next.js 15+ App Router applications - Needing role-based or permission-based navigation filtering - Building internal applications with consistent navigation patterns - Requiring persistent navigation state across sessions - Supporting iOS devices with safe area insets - Wanting smooth, professional animations without performance issues - **Need accordion-style More menu with icon grid submenus** ### Auto-Trigger Keywords This skill automatically activates when you mention: - "mobile nav", "mobile navigation", "mobile bottom navigation" - "bottom navbar", "bottom navigation bar", "bottom bar" - "add mobile nav", "create bottom bar", "implement mobile menu" ## Quick Start ### 1. Install Dependencies ```bash npm install zustand framer-motion lucide-react clsx tailwind-merge ``` Required shadcn/ui components: ```bash npx shadcn@latest add sheet accordion scroll-area ``` ### 2. Copy Core Files Copy all files from `assets/` to your project: ``` assets/ β”œβ”€β”€ components/BottomNav/ β”‚ β”œβ”€β”€ bottom-navbar.tsx β†’ components/BottomNav/ β”‚ β”œβ”€β”€ bottom-nav-item.tsx β†’ components/BottomNav/ β”‚ β”œβ”€β”€ bottom-nav-submenu.tsx β†’ components/BottomNav/ β”‚ β”œβ”€β”€ bottom-nav-more-menu.tsx β†’ components/BottomNav/ ✨ KEY COMPONENT β”‚ β”œβ”€β”€ bottom-nav-minimized.tsx β†’ components/BottomNav/ β”‚ β”œβ”€β”€ types.ts β†’ components/BottomNav/ β”‚ └── index.ts β†’ components/BottomNav/ └── hooks/ β”œβ”€β”€ use-bottom-nav.ts β†’ hooks/ └── use-mobile.tsx β†’ hooks/ ``` **⚠️ IMPORTANT:** Always use the complete `bottom-nav-more-menu.tsx` from assets to ensure proper accordion + icon grid pattern. ### 3. Integrate with Layout ```typescript // app/(routes)/layout.tsx 'use client'; import { cn } from '@/lib/utils'; import { useIsMobile } from '@/hooks/use-mobile'; import { BottomNavbar } from '@/components/BottomNav'; export default function MainLayout({ children }) { const isMobile = useIsMobile(); return ( <>
{children}
); } ``` ### 4. Configure Navigation Structure Create or update `lib/sidebarMenuLink.ts`: ```typescript import { LucideIcon, Home, Users, Building, /* ... */ } from 'lucide-react'; interface MenuItem { href: string; label: string; icon: LucideIcon; active: boolean; submenus: Array<{ href: string; label: string; active: boolean }>; } interface MenuGroup { groupLabel: string; menus: MenuItem[]; } // Example navigation structure export function GetRoleBasedPages( pathname: string, userRole?: CustomRole | null ): MenuGroup[] { return [ { groupLabel: 'Overview', menus: [ { href: '/dashboard', label: 'Dashboard', icon: Home, active: pathname === '/dashboard', submenus: [ { href: '/dashboard', label: 'Dashboard', active: pathname === '/dashboard' }, { href: '/ai-assistant', label: 'AI Assistant', active: pathname === '/ai-assistant' } ] } ] }, { groupLabel: 'User Management', menus: [ { href: '/users', label: 'Users', icon: Users, active: pathname.startsWith('/users'), submenus: [ { href: '/users/list', label: 'User List', active: pathname === '/users/list' }, { href: '/users/roles', label: 'Roles', active: pathname === '/users/roles' } ] } ] }, // ... first 4 groups appear in navbar // Groups 5+ appear in More menu with accordion + grid layout { groupLabel: 'Organization Management', menus: [ { href: '/organization', label: 'Organization', icon: Building, active: pathname.startsWith('/organization'), submenus: [ { href: '/organization/institutions', label: 'Institutions', active: false }, { href: '/organization/degrees', label: 'Degrees', active: false }, { href: '/organization/departments', label: 'Departments', active: false }, { href: '/organization/programs', label: 'Programs', active: false }, { href: '/organization/semesters', label: 'Semesters', active: false }, { href: '/organization/sections', label: 'Sections', active: false }, { href: '/organization/courses', label: 'All Courses', active: false }, { href: '/organization/mappings', label: 'Course Mappings', active: false } ] } ] } ]; } ``` ### 5. Verify Implementation Test checklist: - βœ… Navbar appears on mobile (< 1024px width) - βœ… Hidden on desktop (β‰₯ 1024px width) - βœ… Active nav item highlighted - βœ… Submenu expands ABOVE navbar in 3-column grid - βœ… More menu opens as bottom sheet - βœ… More menu shows accordion sections with icon grid - βœ… All accordion groups expanded by default - βœ… Group headers show icon + label + count - βœ… Navigation works correctly - βœ… State persists across refreshes - βœ… iOS safe area insets respected ## Critical Implementation Notes ### ⚠️ More Menu Pattern - MUST FOLLOW The More menu MUST use this exact pattern: ```typescript // bottom-nav-more-menu.tsx !open && onClose()}> All Menus {/* Accordion with ALL groups expanded by default */} g.id)}> {groups.map((group) => (
{/* Icon badge */}
{/* Label */} {group.groupLabel} {/* Count */} {group.menus.length}
{/* 3-column icon grid */}
{group.menus.map((item) => ( ))}
))}
``` **Key Requirements:** 1. `Accordion type="multiple"` - Allows multiple sections open simultaneously 2. `defaultValue={groups.map(g => g.id)}` - All groups expanded by default 3. 3-column grid (`grid-cols-3`) for submenu items 4. Icon + label for each item 5. Group header shows count of items ### Common Mistakes to Avoid ❌ **DON'T** create flat list More menu: ```typescript // WRONG - Flat list layout
{groups.map(group => (

{group.groupLabel}

    {group.menus.map(item => (
  • {item.label}
  • ))}
))}
``` βœ… **DO** use accordion with icon grid (see above) ❌ **DON'T** place submenu below navbar: ```typescript // WRONG - Submenu below navbar // Wrong position ``` βœ… **DO** place submenu inside navbar, above items: ```typescript ``` ## File Organization After implementation: ``` your-project/ β”œβ”€β”€ components/ β”‚ └── BottomNav/ β”‚ β”œβ”€β”€ bottom-navbar.tsx (Main orchestrator) β”‚ β”œβ”€β”€ bottom-nav-item.tsx (Individual nav button) β”‚ β”œβ”€β”€ bottom-nav-submenu.tsx (3-column grid dropdown) β”‚ β”œβ”€β”€ bottom-nav-more-menu.tsx (Accordion + grid modal) ✨ β”‚ β”œβ”€β”€ bottom-nav-minimized.tsx (Optional minimized state) β”‚ β”œβ”€β”€ types.ts (TypeScript definitions) β”‚ └── index.ts (Barrel export) β”œβ”€β”€ hooks/ β”‚ β”œβ”€β”€ use-bottom-nav.ts (Zustand store) β”‚ └── use-mobile.tsx (Mobile detection) β”œβ”€β”€ lib/ β”‚ β”œβ”€β”€ sidebarMenuLink.ts (Navigation structure) β”‚ └── utils.ts (cn utility) └── app/ └── (routes)/ └── layout.tsx (Integration point) ``` ## Resources ### References (`references/`) 1. **`screenshots/`** - Visual reference from MyJKKN app - `myjkkn-dashboard.png` - Main navbar view - `myjkkn-submenu-dropdown.png` - 3-column submenu grid - `myjkkn-more-menu.png` - Accordion More menu with icon grid - `README.md` - Detailed visual documentation 2. **`complete-implementation.md`** - Full step-by-step implementation guide 3. **`component-reference.md`** - Complete API documentation 4. **`customization-guide.md`** - Theming and styling guide 5. **`integration-guide.md`** - Auth and layout integration 6. **`troubleshooting.md`** - Common issues and solutions ### Assets (`assets/`) 1. **`components/BottomNav/`** - Complete component implementations 2. **`hooks/`** - State management and utilities 3. **`examples/`** - Implementation examples ## Usage Patterns ### For New Projects 1. Copy all files from `assets/` to appropriate locations 2. Install dependencies 3. Configure navigation structure 4. Integrate with main layout 5. Test on mobile devices 6. Verify accordion More menu pattern ### For Existing Projects 1. Review `references/screenshots/` for visual pattern 2. Copy latest components from `assets/` 3. Update More menu to use accordion + grid pattern 4. Test for feature parity with screenshots 5. Gradual rollout with feature flags ### Troubleshooting Wrong UI Pattern **Problem:** More menu shows flat list instead of accordion grid **Solution:** 1. Verify you copied latest `bottom-nav-more-menu.tsx` from `assets/` 2. Check accordion configuration: ```typescript g.id)}> ``` 3. Check grid layout in AccordionContent: ```typescript
``` 4. Verify shadcn/ui accordion component is installed **Problem:** Submenu appears below navbar **Solution:** 1. Check submenu placement in `bottom-navbar.tsx` 2. Ensure submenu is INSIDE `