I'm developing a Tauri application with Vite and React and aim to integrate shadcn/ui using Tailwind CSS version 4. However, I'm encountering the following error during setup:
command used:
pnpm dlx shadcn@latest init
Progress: resolved 168, reused 96, downloaded 72, added 168, done
✔ Preflight checks.
✔ Verifying framework. Found Vite.
✖ Validating Tailwind CSS.
✖ Validating import alias.
Current Configuration:
tsconfig.json:
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}
tsconfig.node.json:
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["vite.config.ts"]
}
vite.config.ts:
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
import path from "path";
const host = process.env.TAURI_DEV_HOST;
export default defineConfig(async () => ({
plugins: [react(), tailwindcss()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
clearScreen: false,
server: {
port: 1420,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: "ws",
host,
port: 1421,
}
: undefined,
watch: {
ignored: ["**/src-tauri/**"],
},
},
}));
Assumptions and Issues:
Tailwind CSS Configuration:
I assumed that with Tailwind CSS version 4, a separate tailwind.config.js
file might not be necessary. However, the error suggests that the absence of this configuration is causing issues.
Import Alias:
The shadcn/ui installation guide mentions setting an import alias. Despite configuring aliases in tsconfig.json
and tsconfig.node.json
, the validation fails, indicating that the alias might not be recognized.
Request for Assistance:
Could someone provide guidance on the following:
Is a tailwind.config.js
file required with Tailwind CSS version 4?
If so, what should it include to ensure proper configuration?
How can I correctly set up the import alias to be compatible with shadcn/ui?
Are there specific configurations needed in the tsconfig
files or elsewhere?
Are there additional steps or configurations necessary to integrate shadcn/ui with a Tauri application using Vite and React?
Any insights, examples, or resources would be greatly appreciated.
TL;DR: The Shadcn installation guide is incorrect. Using npm install tailwindcss
installs TailwindCSS v4 by default, but the guide references the v3 installation. To install v3, you can use npm install tailwindcss@3
until Shadcn officially supports TailwindCSS v4. Aside from this, I believe you should be able to overcome the issue by reviewing the TailwindCSS v4 installation steps.
There have been several updates in TailwindCSS v4.
The installation process has changed:
Some older features have been deprecated:
npx tailwindcss
to npx @tailwindcss/cli
- TailwindCSS v4 Docsnpx tailwindcss init
process - StackOverflowA CSS-first configuration has been implemented:
tailwind.config.js
- TailwindCSS v4 Docs@config
directive to legacy JavaScript-config - StackOverflownpm i tailwindcss
installs v4 by default. To install v3, use:
npm install -D tailwindcss@3
Some related:
shadcn/app-tailwind-v4
- GitHubshadcn/ui
#2996 - GitHubThe Shadcn UI installation with Vite guides are still based on TailwindCSS v3. You can either use them with npm install tailwindcss@3
or completely disregard them and follow the steps for TailwindCSS v4 instead:
shadcn-ui/ui
#6446: Not validating after Tailwind v4 update - GitHubshadcn-ui/ui
#6427: Upgrade to TailwindCSS v4 - GitHubshadcn-ui/ui
#6585: Tailwind v4 and React 19 - GitHub