shadcn-vue-admin

repository·main·Indexed 19 days ago

https://github.com/whbbit1999/shadcn-vue-admin

A production-grade admin dashboard UI starter template built with shadcn-vue, Vue 3.5+, and Vite. It features a modern tech stack including Tailwind CSS 4+, Pinia 3+, TanStack Vue Query 5, and TanStack Vue Table 8. The project includes pre-built components such as a collapsible AppSidebar, a global CommandMenuPanel, and a comprehensive DataTable system with support for server-side pagination, faceted filtering, and bulk actions.

Tokens
48.2K
Snippets
167
Records
188
Agent score
64%

What's inside shadcn-vue-admin

  1. Tech Stack Overview

    main

    Shadcn Vue Admin is built on a modern Vue 3.5+ stack. Key technologies include:

    • Core: Vue 3.5+, TypeScript 5.9+, Vite
    • UI: shadcn-vue, reka-ui 2+, Lucide Vue
    • State: Pinia 3+ with pinia-plugin-persistedstate 4+
    • Routing: vue-router 5+ with vite-plugin-vue-layouts 0.11+
    • Styling: Tailwind CSS 4+, tailwindcss-animate 1+
    • Data: TanStack Vue Query 5+, TanStack Vue Table 8+
    • Forms: TanStack Vue Form, Zod 4+
    • Internationalization: vue-i18n 11+
  2. Prerequisites and Version Requirements

    main

    Shadcn Vue Admin has strict version requirements. Ensure your environment matches these specifications to avoid build or runtime errors:

    • Node.js: ≥ 22.x (LTS recommended)
    • pnpm: 10+ (Required package manager)
    • TypeScript: ≥ 5.9.0
  3. Customize the Theme using CSS Variables

    main

    You can customize the visual style of the dashboard by using CSS variables generated by tools like tweakcn.

    1. Copy the generated CSS variables from tweakcn.
    2. Paste them into the project's index.css file.
    3. Update the :root, :dark, and @theme inline sections to apply your custom styles.
  4. Quick Start: Install and Run Shadcn Vue Admin

    main

    To get started with the Shadcn Vue Admin template, ensure you meet the strict version requirements for Node.js, pnpm, and TypeScript. Follow these steps to clone, install, and launch the development server.

    Prerequisites

    • Node.js: ≥ 22.x (LTS recommended)
    • pnpm: 10+
    • TypeScript: ≥ 5.9.0
    # 1. Clone the repository
    git clone https://github.com/Whbbit1999/shadcn-vue-admin.git
    
    # 2. Enter the directory
    cd shadcn-vue-admin
    
    # 3. Install dependencies
    pnpm install
    
    # 4. Start the development server
    pnpm dev
  5. Customize Layouts for Nested Directories

    main

    By default, the project uses a standard layout. If you want specific directories (like pages/errors/ or pages/auth/) to use a different layout or no layout at all, follow these steps.

    Step 1: Create a directory-level layout file

    Create a file in src/pages/ with the same name as the directory you want to target. Use the <route> block to disable the default layout.

    <template>
      <router-view />
    </template>
    
    <route lang="yml">
    meta:
      layout: false # Disables default layout for all sub-routes
    </route>

    Step 2: Handle redundant parent routes

    Creating the file above might generate empty parent routes (e.g., /errors/). To fix this, create an index.vue inside the target directory and perform a redirect using the Vue 3.5+ Composition API.

    <script lang="ts" setup>
    import { useRouter } from 'vue-router'
    
    const router = useRouter()
    // Example: Redirect to a specific sub-route like 404
    router.replace({ name: '/errors/404' })
    </script>
  6. How to disable the default layout for specific pages

    main

    By default, the routing system applies a standard layout. To use a custom layout (or no layout) for pages in directories like pages/errors/ or pages/auth/, you must create a corresponding file in the src/pages/ root to intercept the route and set the layout metadata.

    Step 1: Create the interceptor file

    Create src/pages/auth.vue (or errors.vue) with the following structure:

    <template>
      <router-view />
    </template>
    
    <route lang="yml">
    meta:
      layout: false
    </route>

    Step 2: Handle directory redirects

    Because the file-based routing will still generate empty routes for the directories (e.g., /auth/), you should create an index.vue inside the original directory (e.g., src/pages/auth/index.vue) to redirect users to the correct sub-page:

    <script lang="ts" setup>
    const router = useRouter()
    router.replace({ name: '/auth/login' }) // Replace with your target route
    </script>
  7. Install Shadcn Vue Admin

    main

    Follow these steps to set up the development environment. Ensure you meet the strict version requirements for Node.js, pnpm, and TypeScript before starting.

    # 1. Clone the repository
    git clone https://github.com/Whbbit1999/shadcn-vue-admin.git
    
    # 2. Navigate to project directory
    cd shadcn-vue-admin
    
    # 3. Install dependencies using pnpm 10+
    
    pnpm install
    
    # 4. Start development server
    pnpm dev
  8. Structure of the Marketing page

    main

    The marketing landing page is composed of several specialized components arranged in a vertical stack. It uses the marketing layout as defined in its route metadata. The page sequence is:

    1. Hero: The primary landing section.
    2. Logos: A section for partner or client logos.
    3. Features: A showcase of the product's capabilities.
    4. Evaluation: A section for social proof or evaluations.
    5. PricingPlans: A section displaying different subscription tiers.
    6. Setup: A section detailing how to get started.
    <template>
      <div class="mt-18">
        <Hero />
        <Logos />
        <Features />
        <Evaluation />
        <PricingPlans />
        <Setup />
      </div>
    </template>
  9. Use the Apps dashboard page

    main

    The Apps dashboard page provides a searchable and filterable interface for managing applications. It uses a BasicPage layout and allows users to filter apps by name, connection status (connected vs notConnected), and sort them alphabetically.

    Key Features

    • Search: Filter apps by name using a text input.
    • Status Filtering: Filter by all, connected, or notConnected status.
    • Sorting: Sort the list in ascending (asc) or descending (desc) order by name.
    • Layout: Uses the BasicPage component with a sticky header and a grid-based display for AppCard components.
    <template>
      <BasicPage
        title="Apps"
        description="Apps description"
        sticky
      >
        <!-- Search, Filter, and Sort controls -->
        <main class="grid grid-cols-1 gap-4 mt-2 lg:grid-cols-3">
          <AppCard
            v-for="app in appList" :key="app.name"
            :app="app"
          />
        </main>
      </BasicPage>
    </template>
  10. Structure of the Dashboard Page

    main

    The dashboard page is implemented using a BasicPage layout component which provides a standardized structure for page titles, descriptions, and action buttons. It utilizes a tabbed interface (UiTabs) to switch between different views like Overview, Analytics, and Reports.

    Key components used in this layout:

    • BasicPage: The primary wrapper that handles page metadata and sticky positioning.
    • UiTabs, UiTabsList, UiTabsTrigger, UiTabsContent: Components used to implement the tabbed navigation.
    • #actions slot: A template slot within BasicPage used to place primary action buttons (e.g., a 'Download' button) in the header area.
    <template>
      <BasicPage
        title="workspace"
        description="workspace description"
        sticky
      >
        <template #actions>
          <Button @click="...">
            {{ $t('download') }}
          </Button>
        </template>
    
        <UiTabs :default-value="defaultTab">
          <UiTabsList>
            <UiTabsTrigger v-for="tab in tabs" :key="tab.value" :value="tab.value">
              {{ tab.name }}
            </UiTabsTrigger>
          </UiTabsList>
          <UiTabsContent value="overview">
            <OverviewContent />
          </UiTabsContent>
        </UiTabs>
      </BasicPage>
    </template>