npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gov-components/layout-header-sidebar

v1.0.5

Published

Reusable Header and Sidebar components for React/Next.js projects

Readme

Gov Components Layout Header Sidebar

Reusable Header and Sidebar layout components designed for Next.js applications, pre-styled with Tailwind CSS. Perfect for government

Features

  • Responsive Sidebar: Automatically collapses on mobile, togglable on desktop.
  • Notification System: Built-in notification bell with dropdown list.
  • User Profile: Display user avatar, name, and role.
  • Tailwind CSS: Beautifully styled using Tailwind utility classes.
  • TypeScript: Fully typed for excellent developer experience.

Requirements

  • React 18+
  • Next.js 13+ (App Router recommended)
  • TailwindCSS 3 (Optional, styles are bundled)

Installation

Install the package via npm:

npm install @gov-components/layout-header-sidebar @gov-components/design-tokens

Setup

The library automatically handles style imports. You don't need to manually import design tokens anymore.

If you are using Next.js Transpile Packages (recommended for avoiding build errors):

// next.config.ts
const nextConfig = {
  transpilePackages: ['@gov-components/layout-header-sidebar', '@gov-components/design-tokens'],
};

Tailwind CSS v4 Configuration

If you are using Tailwind CSS v4, you must explicitly include this package in your source detection. Add the @source directive to your main CSS file:

@import "tailwindcss";
@source "../node_modules/@gov-components/layout-header-sidebar";

Usage Guide

1. Basic Layout Setup

Combine Header and SharedSidebar to create a standard dashboard layout.

// app/page.tsx
'use client';

import { Header, SharedSidebar, toggleSidebar, MenuItem } from '@gov-components/layout-header-sidebar';
import { useRouter } from 'next/navigation';

export default function Dashboard() {
    const router = useRouter();

    // 1. Define User Data
    const user = {
        firstName: 'John',
        lastName: 'Doe',
        pictureUrl: 'https://example.com/avatar.jpg',
        role: 'ADMIN' // Optional role badge
    };

    // 2. Define Menu Items
    const menuItems: MenuItem[] = [
        {
            id: 'dashboard',
            title: 'Dashboard',
            path: '/dashboard',
            icon: <span>📊</span> // Can be any React Node (SVG, Icon component)
        },
        {
            id: 'settings',
            title: 'Settings',
            path: '/settings',
            icon: <span>⚙️</span>
        }
    ];

    return (
        <div className="min-h-screen bg-gray-50">
            {/* Header Component */}
            <Header 
                user={user} 
                sidebarId="main-sidebar" // Must match sidebarId in SharedSidebar
            />

            {/* Sidebar Component */}
            <SharedSidebar
                user={user}
                menuItems={menuItems}
                sidebarId="main-sidebar"
                profilePath="/profile" 
                roleLabel="Administrator"
                roleColor="purple" // teal, purple, orange, blue, green
                onNavigate={(path) => router.push(path)}
                onLogout={() => console.log('User logged out')}
            />

            {/* Main Content Area */}
            <main className="lg:pl-64 pt-20 p-8 transition-all duration-300">
                <h1>Welcome to Dashboard</h1>
            </main>
        </div>
    );
}

2. Using Notifications

The Header component accepts a notifications array to display a dropdown.

import { Header, NotificationItem } from '@gov-components/layout-header-sidebar';

const notifications: NotificationItem[] = [
    {
        id: 1,
        title: 'System Update',
        description: 'System maintenance scheduled at midnight.',
        date: '10 mins ago',
        type: 'info', // 'info' | 'success' | 'reminder'
        isRead: false
    },
    {
        id: 2,
        title: 'Task Completed',
        description: 'Your export task has finished successfully.',
        date: '1 hour ago',
        type: 'success',
        isRead: true
    }
];

// In your render:
<Header 
    user={user} 
    notifications={notifications} 
/>

3. Toggling Sidebar Programmatically

You can control the sidebar state from anywhere in your app using the toggleSidebar utility.

import { toggleSidebar } from '@gov-components/layout-header-sidebar';

// Toggle default sidebar ('sidebar', 'sidebar-overlay')
<button onClick={() => toggleSidebar()}>Menu</button>

// Toggle specific sidebar ID
<button onClick={() => toggleSidebar('main-sidebar')}>Menu</button>

API Reference

<Header />

Top navigation bar showing user profile, notification bell, and hamburger menu (mobile).

| Prop | Type | Default | Description | |------|------|---------|-------------| | user | User | - | User information object. | | notifications | NotificationItem[] | [] | List of items for notification dropdown. | | sidebarId | string | 'sidebar' | ID used to toggle the sidebar. | | overlayId | string | 'sidebar-overlay' | ID used to toggle the overlay. | | notificationBell | ReactNode | - | Custom component to replace the bell icon. |

<SharedSidebar />

Responsive sidebar navigation with user profile section.

| Prop | Type | Default | Description | |------|------|---------|-------------| | user | User | - | User information object. | | menuItems | MenuItem[] | [] | Array of navigation items. | | onNavigate | (path: string) => void | - | Callback when a menu item is clicked. | | onLogout | () => void | - | Callback when logout button is clicked. | | roleLabel | string | - | Text to display below user name (e.g. "Admin"). | | roleColor | string | 'orange' | Badge color (teal, blue, orange, purple, green). | | profilePath | string | - | URL path for the user profile page. | | sidebarId | string | 'sidebar' | DOM ID for the sidebar container. | | overlayId | string | 'sidebar-overlay' | DOM ID for the backdrop overlay. |

Type Definitions

User

interface User {
    firstName?: string;
    lastName?: string;
    pictureUrl?: string;
}

MenuItem

interface MenuItem {
    id: string;
    title: string;
    path: string;
    icon?: React.ReactNode;
}

NotificationItem

interface NotificationItem {
    id: string | number;
    title: string;
    description: string;
    date: string;
    type: 'reminder' | 'success' | 'info';
    isRead?: boolean;
}

License

MIT