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

@kataoffical/nextjs

v1.0.5

Published

Reusable dashboard components for NextJS

Readme

@kataoffical/nextjs

Thư viện components dashboard tái sử dụng cho NextJS với Tailwind CSS, được thiết kế để tạo ra các giao diện quản trị hiện đại và responsive.

🚀 Tính năng

  • ✅ Dashboard layout hoàn chỉnh với Sidebar và Header
  • ✅ Responsive design cho mọi thiết bị
  • ✅ Tailwind CSS với custom color palette
  • ✅ TypeScript support đầy đủ
  • ✅ Tree-shaking friendly
  • ✅ Customizable và extensible
  • ✅ Sidebar có thể thu gọn
  • ✅ Dark/Light theme support
  • ✅ Built-in search, notifications, profile menu

📦 Cài đặt

npm install @kataoffical/nextjs
# hoặc
yarn add @kataoffical/nextjs
# hoặc
pnpm add @kataoffical/nextjs

🛠️ Peer Dependencies

Đảm bảo bạn đã cài đặt các dependencies sau:

npm install react react-dom next tailwindcss

⚙️ Cấu hình

1. Cấu hình Tailwind CSS

Thêm đường dẫn đến components của thư viện trong tailwind.config.js:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./src/**/*.{js,ts,jsx,tsx,mdx}",
    "./node_modules/@kataoffical/nextjs/dist/**/*.{js,ts,jsx,tsx}"
  ],
  theme: {
    extend: {
      colors: {
        dashboard: {
          50: '#f8fafc',
          100: '#f1f5f9',
          200: '#e2e8f0',
          300: '#cbd5e1',
          400: '#94a3b8',
          500: '#64748b',
          600: '#475569',
          700: '#334155',
          800: '#1e293b',
          900: '#0f172a',
          primary: '#3b82f6',
          secondary: '#64748b',
          accent: '#10b981',
          background: '#f8fafc',
          surface: '#ffffff',
          text: '#1e293b'
        }
      }
    },
  },
  plugins: [],
}

2. Import CSS trong _app.tsx hoặc layout.tsx

// Next.js App Router (app/layout.tsx)
import '@kataoffical/nextjs/dist/index.css';

// Next.js Pages Router (_app.tsx)
import '@kataoffical/nextjs/dist/index.css';

📖 Sử dụng cơ bản

Dashboard Component

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

import { Dashboard, DashboardConfig } from '@kataoffical/nextjs';

const dashboardConfig: DashboardConfig = {
  title: 'Admin Dashboard',
  logo: '/logo.png',
  sidebar: {
    width: 64,
    collapsible: true,
    items: [
      {
        id: 'dashboard',
        label: 'Dashboard',
        icon: '🏠',
        href: '/dashboard',
        active: true
      },
      {
        id: 'users',
        label: 'Người dùng',
        icon: '👥',
        href: '/users'
      },
      {
        id: 'orders',
        label: 'Đơn hàng',
        icon: '📦',
        href: '/orders',
        children: [
          {
            id: 'orders-list',
            label: 'Danh sách',
            href: '/orders/list'
          },
          {
            id: 'orders-create',
            label: 'Tạo mới',
            href: '/orders/create'
          }
        ]
      }
    ]
  },
  header: {
    showSearch: true,
    showNotifications: true,
    showProfile: true,
    userMenu: [
      {
        label: 'Hồ sơ',
        href: '/profile'
      },
      {
        label: 'Cài đặt',
        href: '/settings'
      },
      { divider: true },
      {
        label: 'Đăng xuất',
        onClick: () => console.log('Logout')
      }
    ]
  }
};

export default function DashboardPage() {
  return (
    <Dashboard config={dashboardConfig}>
      <div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
        <div className="bg-white p-6 rounded-lg shadow">
          <h3 className="text-lg font-semibold text-gray-900">Tổng người dùng</h3>
          <p className="text-3xl font-bold text-blue-600">1,234</p>
        </div>
        
        <div className="bg-white p-6 rounded-lg shadow">
          <h3 className="text-lg font-semibold text-gray-900">Đơn hàng mới</h3>
          <p className="text-3xl font-bold text-green-600">567</p>
        </div>
        
        <div className="bg-white p-6 rounded-lg shadow">
          <h3 className="text-lg font-semibold text-gray-900">Doanh thu</h3>
          <p className="text-3xl font-bold text-purple-600">$12,345</p>
        </div>
        
        <div className="bg-white p-6 rounded-lg shadow">
          <h3 className="text-lg font-semibold text-gray-900">Tăng trưởng</h3>
          <p className="text-3xl font-bold text-orange-600">+23%</p>
        </div>
      </div>
    </Dashboard>
  );
}

Sử dụng Hook useDashboard

'use client';

import { useDashboard, DashboardConfig } from '@kataoffical/nextjs';

const initialConfig: DashboardConfig = {
  title: 'My Dashboard',
  sidebar: {
    items: []
  },
  header: {
    showSearch: true,
    showProfile: true
  }
};

export default function MyDashboard() {
  const { config, updateConfig, updateSidebarItems, loading } = useDashboard(initialConfig);
  
  // Cập nhật sidebar items động
  const handleUpdateMenu = () => {
    updateSidebarItems([
      {
        id: 'new-item',
        label: 'Menu mới',
        icon: '⭐',
        href: '/new'
      }
    ]);
  };

  return (
    <div>
      <button onClick={handleUpdateMenu}>
        Cập nhật menu
      </button>
      {/* Render dashboard với config đã cập nhật */}
    </div>
  );
}

🎨 Customization

Custom Styling

Bạn có thể override các style mặc định bằng cách sử dụng Tailwind classes:

<Dashboard 
  config={config}
  className="custom-dashboard-class"
>
  {/* content */}
</Dashboard>

Custom Sidebar Item

const customSidebarItem = {
  id: 'custom',
  label: 'Custom Item',
  icon: '⚙️',
  onClick: () => {
    // Custom logic
    console.log('Custom item clicked');
  },
  children: [
    {
      id: 'sub1',
      label: 'Sub Item 1',
      href: '/custom/sub1'
    }
  ]
};

📱 Responsive Design

Thư viện được thiết kế responsive với các breakpoint:

  • Mobile: Sidebar ẩn, hiển thị hamburger menu
  • Tablet: Sidebar có thể thu gọn
  • Desktop: Sidebar mở rộng đầy đủ

🔧 API Reference

DashboardConfig

interface DashboardConfig {
  title: string;              // Tiêu đề dashboard
  logo?: string;              // URL logo
  theme?: 'light' | 'dark';   // Theme (coming soon)
  sidebar?: SidebarConfig;    // Cấu hình sidebar
  header?: HeaderConfig;      // Cấu hình header
}

SidebarConfig

interface SidebarConfig {
  width?: number;             // Độ rộng sidebar (default: 64)
  collapsible?: boolean;      // Có thể thu gọn (default: true)
  items: SidebarItem[];       // Danh sách menu items
}

SidebarItem

interface SidebarItem {
  id: string;                 // ID unique
  label: string;              // Nhãn hiển thị
  icon?: string;              // Icon (emoji hoặc SVG)
  href?: string;              // Link URL
  onClick?: () => void;       // Custom click handler
  children?: SidebarItem[];   // Menu con
  active?: boolean;           // Trạng thái active
}

HeaderConfig

interface HeaderConfig {
  showSearch?: boolean;       // Hiển thị search box
  showNotifications?: boolean; // Hiển thị notifications
  showProfile?: boolean;      // Hiển thị profile menu
  userMenu?: UserMenuItem[];  // Menu người dùng
}

🎯 Examples

1. Dashboard đơn giản

const simpleConfig: DashboardConfig = {
  title: 'Simple Dashboard',
  sidebar: {
    items: [
      { id: 'home', label: 'Trang chủ', icon: '🏠', href: '/' },
      { id: 'about', label: 'Giới thiệu', icon: 'ℹ️', href: '/about' }
    ]
  }
};

2. Dashboard với menu nhiều cấp

const advancedConfig: DashboardConfig = {
  title: 'Advanced Dashboard',
  sidebar: {
    items: [
      {
        id: 'ecommerce',
        label: 'E-commerce',
        icon: '🛒',
        children: [
          { id: 'products', label: 'Sản phẩm', href: '/products' },
          { id: 'categories', label: 'Danh mục', href: '/categories' },
          {
            id: 'orders',
            label: 'Đơn hàng',
            children: [
              { id: 'pending', label: 'Chờ xử lý', href: '/orders/pending' },
              { id: 'completed', label: 'Hoàn thành', href: '/orders/completed' }
            ]
          }
        ]
      }
    ]
  },
  header: {
    showSearch: true,
    showNotifications: true,
    showProfile: true
  }
};

3. Dashboard với custom actions

const interactiveConfig: DashboardConfig = {
  title: 'Interactive Dashboard',
  sidebar: {
    items: [
      {
        id: 'refresh',
        label: 'Làm mới',
        icon: '🔄',
        onClick: () => {
          window.location.reload();
        }
      }
    ]
  }
};

🚀 Development

Build thư viện

npm run build

Development mode

npm run dev

Testing

npm run test

📄 License

MIT License - xem file LICENSE để biết thêm chi tiết.

🤝 Contributing

Contributions, issues và feature requests đều được chào đón!

  1. Fork repository
  2. Tạo feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add some AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Mở Pull Request

📞 Support


Made with ❤️ by KataOffical

Development

npm run dev

Test

npm run pre-check

Build và publish

npm run build-and-publish