TailAdmin Free Next.js Admin Dashboard

repository·main·Indexed 25 days ago

https://github.com/tailadmin/free-nextjs-admin-dashboard

A free and open-source admin dashboard template built with Next.js 16.x, React 19, TypeScript, and Tailwind CSS V4. It includes a comprehensive set of UI components such as Modals and Tables, a centralized SVG icon library, and built-in state management for themes and sidebars via React Context.

Tokens
2.7K
Snippets
3
Records
15
Agent score
82%

What's inside TailAdmin

  1. TailAdmin Next.js Tech Stack Overview

    main

    TailAdmin is a dashboard template built using modern web technologies to support server-side rendering (SSR), static site generation (SSG), and seamless API route integration.

    Core Technologies:

    • Framework: Next.js 16.x
    • Library: React 19
    • Language: TypeScript
    • Styling: Tailwind CSS V4
  2. Compare Free vs Pro versions of TailAdmin

    main

    TailAdmin is available in two versions depending on your project requirements:

    Free Version

    • 1 Unique Dashboard
    • 30+ dashboard components
    • 50+ UI elements
    • Basic Figma design files
    • Community support

    Pro Version

    • 7 Unique Dashboards (Analytics, Ecommerce, Marketing, CRM, SaaS, Stocks, Logistics)
    • 500+ dashboard components and UI elements
    • Complete Figma design file
    • Email support
  3. Install TailAdmin Next.js

    main

    Follow these steps to set up the TailAdmin Next.js dashboard template on your local machine.

    Prerequisites

    • Node.js: version 18.x or later (Node.js 20.x or later is recommended).

    Setup Steps

    1. Clone the repository:

      git clone https://github.com/TailAdmin/free-nextjs-admin-dashboard.git

      Note: Windows users should place the repository near the root of the drive to avoid cloning issues.

    2. Install dependencies:

      npm install
      # or
      yarn install

      Tip: If you encounter peer-dependency errors, use the --legacy-peer-deps flag.

    3. Start the development server:

      npm run dev
      # or
      yarn dev
    git clone https://github.com/TailAdmin/free-nextjs-admin-dashboard.git
    
    npm install
    
    npm run dev
  4. Manage sidebar state with SidebarProvider and useSidebar

    main

    The sidebar's visibility, expansion, and navigation state are managed via a React Context provider. To use these features, you must wrap your application (or the relevant part of the layout) in the SidebarProvider. You can then access and manipulate the sidebar state in any child component using the useSidebar hook.

    Important: Calling useSidebar in a component that is not a descendant of SidebarProvider will throw an error: "useSidebar must be used within a SidebarProvider".

  5. Configure Prettier with Tailwind CSS plugin

    main

    The project uses Prettier for code formatting and includes the prettier-plugin-tailwindcss plugin. This plugin automatically sorts Tailwind CSS classes in the recommended order to maintain consistency across the codebase. To ensure your local environment matches the project's formatting, ensure this plugin is installed and recognized by your Prettier configuration.

    module.exports = {
        plugins: ['prettier-plugin-tailwindcss'],
    }
  6. Configure ESLint for TailAdmin Next.js

    main

    TailAdmin uses the new ESLint flat configuration format (eslint.config.mjs). The configuration integrates Next.js core web vitals rules and TypeScript support. It also defines specific global ignores to prevent ESLint from scanning build artifacts and Next.js environment files.

    To maintain the project's linting standards, ensure your environment supports ESLint flat config and the following dependencies: eslint-config-next (for core-web-vitals and typescript configs) and eslint.

    import nextVitals from "eslint-config-next/core-web-vitals";
    import nextTs from "eslint-config-next/typescript";
    import { defineConfig, globalIgnores } from "eslint/config";
    
    const eslintConfig = defineConfig([
      ...nextVitals,
      ...nextTs,
      globalIgnores([
        ".next/**",
        "out/**",
        "build/**",
        "next-env.d.ts",
      ]),
    ]);
    
    export default eslintConfig;
  7. Use the Modal component

    main

    The Modal component is a client-side React component used to display content in an overlay. It handles backdrop clicking, the Escape key to close, and prevents body scrolling when open.

    Key features:

    • Backdrop: Clicking the backdrop closes the modal (unless isFullscreen is true).
    • Keyboard Support: Pressing Escape triggers the onClose callback.
    • Scroll Lock: Automatically sets document.body.style.overflow to hidden when open to prevent background scrolling.
    • Fullscreen Mode: When isFullscreen is enabled, the modal occupies the full width and height of the viewport and removes the backdrop.
  8. Use exported icons from the icon library

    main

    The application provides a centralized icon library exported from src/icons/index.tsx. These icons are imported as React components (SVG-based) and can be used directly in your components.

    Commonly used icons include:

    • Navigation/Direction: ArrowUpIcon, ArrowDownIcon, ArrowRightIcon, ChevronDownIcon, ChevronUpIcon, ChevronLeftIcon.
    • UI Feedback: CheckCircleIcon, AlertIcon, InfoIcon, ErrorIcon, CloseIcon, PlusIcon.
    • Content/Media: VideoIcon, AudioIcon, FileIcon, FolderIcon, DocsIcon.
    • User/System: UserIcon, UserCircleIcon, LockIcon, BellIcon, MailIcon, TimeIcon.
    • Data/Layout: GridIcon, ListIcon, TableIcon, PieChartIcon, BoxIcon.
  9. Build a table using Table, TableHeader, TableBody, TableRow, and TableCell

    main

    The src/components/ui/table module provides a set of primitive components to construct structured data tables using standard HTML table elements.

    Components

    • Table: The root container. It applies min-w-full by default.
    • TableHeader: Renders the <thead> element.
    • TableBody: Renders the <tbody> element.
    • TableRow: Renders the <tr> element.
    • TableCell: Renders either a <th> or <td> element based on the isHeader prop.

    Props

    All components accept an optional className string for custom styling.

    ComponentPropTypeDescription
    TablechildrenReactNodeTable content (thead, tbody, etc.)
    TableclassNamestringOptional styling
    TableHeaderchildrenReactNodeHeader row(s)
    TableHeaderclassNamestringOptional styling
    TableBodychildrenReactNodeBody row(s)
    TableBodyclassNamestringOptional styling
    TableRowchildrenReactNodeCells (th or td)
    TableRowclassNamestringOptional styling
    TableCellchildrenReactNodeCell content
    TableCellisHeaderbooleanIf true, renders <th>; otherwise <td>. Defaults to false.
    TableCellclassNamestringOptional styling
  10. Manage theme state with ThemeProvider and useTheme

    main

    The dashboard uses a React Context to manage light and dark modes. To enable theme switching throughout your application, wrap your component tree with the ThemeProvider. You can then access the current theme and the toggleTheme function using the useTheme hook.

    Key Behaviors:

    • Persistence: The selected theme is automatically saved to localStorage under the key "theme".
    • DOM Integration: When the theme is set to "dark", the "dark" class is added to document.documentElement. When set to "light", the class is removed.
    • Default State: If no theme is found in localStorage, the application defaults to "light" mode.
  11. Use the useSidebar hook to control sidebar behavior

    main

    The useSidebar hook provides access to the following properties and methods to control the sidebar's state:

    State Properties:

    • isExpanded: boolean - Indicates if the sidebar is in its expanded state (on desktop).
    • isMobileOpen: boolean - Indicates if the mobile sidebar overlay is currently open.
    • isHovered: boolean - Indicates if the sidebar is currently being hovered.
    • activeItem: string | null - The identifier of the currently active navigation item.
    • openSubmenu: string | null - The identifier of the currently open submenu.

    Actions:

    • toggleSidebar: () => void - Toggles the expanded state of the sidebar.
    • toggleMobileSidebar: () => void - Toggles the mobile sidebar visibility.
    • setIsHovered: (isHovered: boolean) => void - Manually sets the hover state.
    • setActiveItem: (item: string | null) => void - Sets the active navigation item.
    • toggleSubmenu: (item: string) => void - Toggles a specific submenu open or closed based on the provided item ID.
  12. ModalProps reference

    main

    The Modal component accepts the following props:

    PropTypeDefaultDescription
    isOpenbooleanRequiredControls the visibility of the modal.
    onClose() => voidRequiredCallback function executed when the user clicks the close button, clicks the backdrop, or presses Escape.
    childrenReact.ReactNodeRequiredThe content to be rendered inside the modal.
    classNamestringundefinedAdditional CSS classes to apply to the modal content container.
    showCloseButtonbooleantrueWhether to render the close button (X icon) in the top-right corner.
    isFullscreenbooleanfalseIf true, the modal takes up the full screen (w-full h-full) and the backdrop is not rendered.