TailAdmin React Documentation

repository·main·Indexed 22 days ago

https://github.com/tailadmin/free-react-tailwind-admin-dashboard

A free and open-source admin dashboard template built with React 19, TypeScript, and Tailwind CSS v4. It includes a comprehensive set of UI components such as tables, modals, dropdowns, and a responsive sidebar, along with built-in support for dark mode and dynamic page metadata management.

Tokens
3.3K
Snippets
2
Records
21
Agent score
77%

What's inside TailAdmin React

  1. Overview of TailAdmin React components and tech stack

    main

    TailAdmin is a dashboard template built using:

    • React 19
    • TypeScript
    • Tailwind CSS v4

    Included Components

    The template provides a variety of pre-designed UI elements, including:

    • Navigation: Sophisticated and accessible sidebar.
    • Data Visualization: Tables, Line charts, and Bar charts.
    • Forms & Inputs: Authentication forms, input elements, and date pickers.
    • UI Elements: Alerts, Dropdowns, Modals, Buttons, FAQ & Accordion, Testimonials, and Carousels.
    • Pages: Prebuilt profile management and 404 pages.
    • Features: Dark Mode support.
  2. Install TailAdmin React

    main

    Follow these steps to set up the TailAdmin React 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-react-tailwind-admin-dashboard.git

      Note for Windows users: If you encounter issues during cloning, place the repository near the root of your drive.

    2. Install dependencies:

      npm install
      # or
      yarn install
    3. Start the development server:

      npm run dev
      # or
      yarn dev
    git clone https://github.com/TailAdmin/free-react-tailwind-admin-dashboard.git
    
    npm install
    
    npm run dev
  3. Build a table using Table components

    main

    The Table component library provides a set of modular components to build semantic HTML tables using Tailwind CSS. You compose a table by nesting TableHeader, TableBody, TableRow, and TableCell components inside a Table container.

    Component API

    • Table: The root container. Accepts children (the table structure) and an optional className.
    • TableHeader: Renders a <thead> element. Accepts children and an optional className.
    • TableBody: Renders a <tbody> element. Accepts children and an optional className.
    • TableRow: Renders a <tr> element. Accepts children and an optional className.
    • TableCell: Renders either a <th> or <td> element.
      • isHeader: (boolean) If true, renders as <th>. Defaults to false (<td>).
      • children: The content of the cell.
      • className: Optional styling.
  4. Configure ESLint for TypeScript and React

    main

    The project uses a flat configuration file (eslint.config.js) powered by typescript-eslint. It is configured to enforce recommended rules for JavaScript and TypeScript, while providing specific support for React Hooks and React Refresh.

    Key configuration details:

    • Ignored directories: The dist directory is ignored by default.
    • Supported files: Rules are applied to all .ts and .tsx files.
    • Environment: Configured for browser globals and ecmaVersion: 2020.
    • React Refresh: The rule react-refresh/only-export-components is set to warn with { allowConstantExport: true } to support Fast Refresh while allowing constant exports.
    import js from '@eslint/js'
    import globals from 'globals'
    import reactHooks from 'eslint-plugin-react-hooks'
    import reactRefresh from 'eslint-plugin-react-refresh'
    import tseslint from 'typescript-eslint'
    
    export default tseslint.config(
      { ignores: ['dist'] },
      {
        extends: [js.configs.recommended, ...tseslint.configs.recommended],
        files: ['**/*.{ts,tsx}'],
        languageOptions: {
          ecmaVersion: 2020,
          globals: globals.browser,
        },
        plugins: {
          'react-hooks': reactHooks,
          'react-refresh': reactRefresh,
        },
        rules: {
          ...reactHooks.configs.recommended.rules,
          'react-refresh/only-export-components': [
            'warn',
            { allowConstantExport: true },
          ],
        },
      },
    )
  5. Compare Free vs Pro versions of TailAdmin

    main

    TailAdmin offers a Free version and a Pro version with different feature sets.

    Free Version

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

    Pro Version

    • 7 Unique Dashboards: Analytics, Ecommerce, Marketing, CRM, SaaS, Stocks, and Logistics.
    • 500+ dashboard components and UI elements
    • Complete Figma design file
    • Email support
  6. Use the ThemeToggleButton component

    main

    The ThemeToggleButton is a pre-styled React component used to switch the application between light and dark modes. It relies on the useTheme hook from the ThemeContext to access the toggleTheme function. When clicked, it triggers the theme change and automatically updates the UI based on the current theme state.

    To use it, ensure your component tree is wrapped in the appropriate ThemeProvider (provided by the project's context system) and then import and render the component.

    Note: The component uses Tailwind CSS classes for styling and handles icon visibility (sun/moon) based on the dark class presence in the DOM.

  7. Import SVGs as React components using the ?react suffix

    main

    The project supports importing SVG files directly as React components by appending the ?react query parameter to the import path. This allows you to use the SVG as a standard React functional component and pass props like className, style, or onClick directly to it.

    When using this pattern, the module provides two exports:

    1. A default export which is the string URL/path to the SVG file.
    2. A named export ReactComponent which is the React component itself.
  8. Use the Modal component

    main

    The Modal component is a reusable UI element used to display content in an overlay. It handles backdrop clicking, the 'Escape' key to close, and prevents body scrolling when active.

    Key features:

    • Backdrop Close: Clicking the backdrop closes the modal (unless isFullscreen is true).
    • Keyboard Support: Pressing the Escape key 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 expands to fill the entire viewport and removes the backdrop.
  9. DropdownProps reference

    main

    The Dropdown component accepts the following props:

    PropTypeDescription
    isOpenbooleanDetermines if the dropdown is rendered.
    onClose() => voidCallback function triggered when clicking outside the dropdown or on a .dropdown-toggle element.
    childrenReact.ReactNodeThe content to be displayed inside the dropdown container.
    classNamestring (optional)Additional CSS classes to apply to the dropdown container.
  10. TableCell component API

    main

    The TableCell component is used to render individual cells within a TableRow. It dynamically switches between <th> and <td> tags based on the isHeader prop.

    PropTypeDefaultDescription
    childrenReactNode-The content to be displayed inside the cell.
    isHeaderbooleanfalseIf true, the component renders a <th> element; otherwise, it renders a <td>.
    classNamestring-Optional Tailwind CSS classes for cell styling.