Tailwind-V4-Vite
Tailwind-V4-Vite是一款design方向的AI技能,核心价值是Tailwind CSS v4+ installation and configuration for Vite projects using the official @tailwindcss/vite plugin,可用于解决开发者在design领域的实际问题,帮助用户提升效率、自动化重复任务或优化工作流。
Tailwind CSS v4+ installation and configuration for Vite projects using the official @tailwindcss/vite plugin
mkdir -p ./skills/tailwind-v4-vite && curl -sfL https://raw.githubusercontent.com/github/awesome-copilot/main/skills/tailwind-v4-vite/SKILL.md -o ./skills/tailwind-v4-vite/SKILL.md Run in terminal / PowerShell. Requires curl (Unix) or PowerShell 5+ (Windows).
Skill Content
# Tailwind CSS v4+ Installation with Vite
Instructions for installing and configuring Tailwind CSS version 4 and above using the official Vite plugin. Tailwind CSS v4 introduces a simplified setup that eliminates the need for PostCSS configuration and tailwind.config.js in most cases.
Key Changes in Tailwind CSS v4
- **No PostCSS configuration required** when using the Vite plugin
- **No tailwind.config.js required** - configuration is done via CSS
- **New @tailwindcss/vite plugin** replaces the PostCSS-based approach
- **CSS-first configuration** using `@theme` directive
- **Automatic content detection** - no need to specify content paths
Installation Steps
Step 1: Install Dependencies
Install `tailwindcss` and the `@tailwindcss/vite` plugin:
npm install tailwindcss @tailwindcss/viteStep 2: Configure Vite Plugin
Add the `@tailwindcss/vite` plugin to your Vite configuration file:
// vite.config.ts
import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
tailwindcss(),
],
})For React projects with Vite:
// vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
plugins: [
react(),
tailwindcss(),
],
})Step 3: Import Tailwind CSS
Add the Tailwind CSS import to your main CSS file (e.g., `src/index.css` or `src/App.css`):
@import "tailwindcss";Step 4: Verify CSS Import in Entry Point
Ensure your main CSS file is imported in your application entry point:
// src/main.tsx or src/main.ts
import './index.css'Step 5: Start Development Server
Run the development server to verify installation:
npm run devWhat NOT to Do in Tailwind v4
Do NOT Create tailwind.config.js
Tailwind v4 uses CSS-first configuration. Do not create a `tailwind.config.js` file unless you have specific legacy requirements.
// ❌ NOT NEEDED in Tailwind v4
module.exports = {
content: ['./src/**/*.{js,ts,jsx,tsx}'],
theme: {
extend: {},
},
plugins: [],
}Do NOT Create postcss.config.js for Tailwind
When using the `@tailwindcss/vite` plugin, PostCSS configuration for Tailwind is not required.
// ❌ NOT NEEDED when using @tailwindcss/vite
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}Do NOT Use Old Directives
The old `@tailwind` directives are replaced by a single import:
/* ❌ OLD - Do not use in Tailwind v4 */
@tailwind base;
@tailwind components;
@tailwind utilities;
/* ✅ NEW - Use this in Tailwind v4 */
@import "tailwindcss";CSS-First Configuration (Tailwind v4)
Custom Theme Configuration
Use the `@theme` directive in your CSS to customize your design tokens:
@import "tailwindcss";
@theme {
--color-primary: #3b82f6;
--color-secondary: #64748b;
--font-sans: 'Inter', system-ui, sans-serif;
--radius-lg: 0.75rem;
}Adding Custom Utilities
Define custom utilities directly in CSS:
@import "tailwindcss";
@utility content-auto {
content-visibility: auto;
}
@utility scrollbar-hidden {
scrollbar-width: none;
&::-webkit-scrollbar {
display: none;
}
}Adding Custom Variants
Define custom variants in CSS:
@import "tailwindcss";
@variant hocus (&:hover, &:focus);
@variant group-hocus (:merge(.group):hover &, :merge(.group):focus &);Verification Checklist
After installation, verify:
- [ ] `tailwindcss` and `@tailwindcss/vite` are in `package.json` dependencies
- [ ] `vite.config.ts` includes the `tailwindcss()` plugin
- [ ] Main CSS file contains `@import "tailwindcss";`
- [ ] CSS file is imported in the application entry point
- [ ] Development server runs without errors
- [ ] Tailwind utility classes (e.g., `text-blue-500`, `p-4`) render correctly
🎯 Best For
- Claude users
- GitHub Copilot users
- Designers
- Creative professionals
- Product teams
💡 Use Cases
- Design system documentation
- Component specification creation
📖 How to Use This Skill
- 1
Install the Skill
Copy the install command from the Terminal tab and run it. The SKILL.md file downloads to your local skills directory.
- 2
Load into Your AI Assistant
Open Claude or GitHub Copilot and reference the skill. Paste the SKILL.md content or use the system prompt tab.
- 3
Apply Tailwind-V4-Vite to Your Work
Provide context for your task — paste source material, describe your audience, or share existing work to guide the AI.
- 4
Review and Refine
Edit the AI output for accuracy, tone, and completeness. Add human insight where the AI lacks context.
❓ Frequently Asked Questions
Does Tailwind-V4-Vite generate production-ready design specs?
It generates detailed specifications that developers can use directly. Review and adjust for your specific design system.
How do I install Tailwind-V4-Vite?
Copy the install command from the Terminal tab and run it. The skill downloads to ./skills/tailwind-v4-vite/SKILL.md, ready to use.
Can I customize this skill for my team?
Absolutely. Edit the SKILL.md file to add team-specific instructions, examples, or workflows.
⚠️ Common Mistakes to Avoid
Not reading the full skill
Skills contain important context and edge cases beyond the quick start.