mcpField
V
vite-shadcn-tailwind4

vite-shadcn-tailwind4

github.com/igorwarzochaDevelopment122124 installsUpdated 38w ago
Repository

About vite-shadcn-tailwind4

vite-shadcn-tailwind4 is a setup skill for adding shadcn/ui with Tailwind CSS v4 to Vite projects. It checks prerequisites and guides configuration, component installation, optional AI elements, and verification.

Key features

  1. 01Check Vite and Tailwind prerequisites
  2. 02Configure TypeScript path aliases
  3. 03Verify Vite plugin and alias
  4. 04Initialize shadcn and add components
  5. 05Install dependencies and validate setup

Use cases

  1. 01Setting up shadcn/ui in a Vite project
  2. 02Fixing configuration for the shadcn CLI
  3. 03Adding shadcn components and optional AI elements
  4. 04Checking dependencies and TypeScript errors

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/igorwarzocha/opencode-workflows --skill vite-shadcn-tailwind4

After installing, type/vite-shadcn-tailwind4in Claude Code to confirm it loaded.

Details

From the project README
Protocol for initializing shadcn/ui with Tailwind CSS v4 in a **Vite** project. This skill is Vite-specific due to: - Vite's solution-style `tsconfig.json` (references pattern) - `@tailwindcss/vite` plugin requirement - CSS entry file conventions (`src/index.css`)

For Next.js, Remix, or other frameworks, You MUST use their respective shadcn installation guides.

<question_tool>

  • Batching Rule: You MUST use only for 2+ related questions; single questions use plain text.
  • Syntax Constraints: header max 12 chars, labels 1-5 words, mark defaults with (Recommended).
  • Purpose: Clarify component selection, style preferences, and optional AI elements before running shadcn CLI. </question_tool>
## Step 1: Verify Prerequisites Check that the project is ready: - `vite.config.ts` MUST exist. - `package.json` MUST contain `tailwindcss` (v4+) and `@tailwindcss/vite`. - TypeScript MUST be configured.

If prerequisites are missing, You MUST help the user set up Tailwind v4 first.

## Step 2: Fix TypeScript Aliases The shadcn CLI fails if paths aren't in the root `tsconfig.json`. Vite uses a solution-style config with references, but shadcn doesn't parse those.

Action: You MUST update tsconfig.json to include compilerOptions:

{
  "files": [],
  "references": [
    { "path": "./tsconfig.app.json" },
    { "path": "./tsconfig.node.json" }
  ],
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["./src/*"]
    }
  }
}
## Step 3: Verify Vite Config You MUST confirm `vite.config.ts` has the Tailwind plugin and path alias:
import tailwindcss from "@tailwindcss/vite";
import path from "path";

export default defineConfig({
  plugins: [react(), tailwindcss()],
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
});
## Step 4: Initialize Shadcn You MUST instruct the user to run: ```bash npx shadcn@latest init ```

You SHOULD recommend these settings:

  • Style: New York
  • Base Color: Neutral or Zinc
  • CSS Variables: Yes

You MUST wait for user confirmation before continuing.

## Step 5: Add Components You MUST instruct the user to run: ```bash npx shadcn@latest add ```

You SHOULD instruct them to select all components (a then Enter).

You MUST wait for user confirmation before continuing.

## Step 6: Add Extensions (Optional) If user wants AI elements, You MUST instruct them to run: ```bash npx shadcn@latest add @ai-elements/all ```

You SHOULD instruct them to answer NO to all overwrite prompts.

You MUST wait for user confirmation before continuing.

## Step 7: Install Missing Dependencies The CLI MAY miss dependencies. You MUST check `package.json` and install any missing.

Required packages:

  • tw-animate-css (devDep) - v4 replacement for tailwindcss-animate
  • tailwind-merge (dep) - used by cn() utility
  • clsx (dep) - used by cn() utility
  • class-variance-authority (dep) - used by shadcn components

You MUST run if any are missing:

npm install tailwind-merge clsx class-variance-authority
npm install -D tw-animate-css
## Step 8: Clean CSS for v4 Compliance You MUST rewrite `src/index.css` to match strict v4 structure:
@import "tailwindcss";
@import "tw-animate-css";

@custom-variant dark (&:is(.dark *));

@theme inline {
  /* Variable mappings: --color-X: var(--X); */
}

:root {
  /* Token definitions using oklch() */
}

.dark {
  /* Dark mode tokens using oklch() */
}

@layer base {
  * {
    @apply border-border outline-ring/50;
  }
  body {
    @apply bg-background text-foreground;
  }
}

You MUST remove these if present:

  • @media (prefers-color-scheme) blocks
  • Duplicate @theme blocks (keep only @theme inline)
  • @config directives
## Step 9: Verify Setup You MUST run typecheck to catch any issues: ```bash npm run lint ```

You MUST fix any TypeScript errors before marking setup complete.

Comments

Markdown supported