DEV Community

Cover image for Install Tailwind CSS v4 in a Vue 3 + Vite Project
Stephen Akugbe
Stephen Akugbe

Posted on

44

Install Tailwind CSS v4 in a Vue 3 + Vite Project

Tailwind CSS v4 is here, bringing a more streamlined installation process and performance improvements. However, if you check the official Tailwind CSS documentation, you might not find explicit installation instructions for Vue 3 with Vite. This guide will walk you through the process step-by-step.

What’s New in Tailwind CSS v4?

Tailwind CSS v4 introduces several improvements, including:

  • No PostCSS configuration required – You no longer need postcss.config.js.
  • Faster build times – Thanks to better optimizations.
  • New @tailwindcss/vite plugin – Tailwind now integrates more seamlessly with Vite.

Why Vue 3 Instead of Nuxt?

I'm sure you're wondering why I would need Vue 3 instead of just using Nuxt. Vue 3 is a great choice if you’re building a SPA or an SSR-ready app without the full complexity of Nuxt. Here’s why you might choose Vue over Nuxt:

  • Better Performance: Vue 3 is lightweight and doesn’t add the overhead that Nuxt brings.
  • More Control: With Vue 3, you decide how your app is structured rather than following Nuxt’s conventions.
  • No Need for SSR: If you don’t need server-side rendering (SSR) or static site generation (SSG), Vue 3 is simpler.
  • Faster Builds: Since Nuxt includes additional features, Vue 3 + Vite can be faster for development and deployment.

Installing Tailwind CSS v4 in Vue 3 + Vite

Step 1: Create a Vue 3 Project with Vite

If you don’t already have a Vue 3 project set up, create one using Vite:

npm create vite@latest my-vue-app -- --template vue
cd my-vue-app
npm install
Enter fullscreen mode Exit fullscreen mode

Step 2: Install Tailwind CSS v4

Run the following command to install Tailwind CSS v4 along with its Vite plugin:

npm install -D tailwindcss @tailwindcss/vite
Enter fullscreen mode Exit fullscreen mode

Step 3: Configure Vite to Use Tailwind CSS

Edit vite.config.ts (or vite.config.js if using JavaScript) and add Tailwind CSS as a plugin:

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import tailwindcss from '@tailwindcss/vite'

export default defineConfig({
  plugins: [
    vue(),
    tailwindcss(),
  ],
})
Enter fullscreen mode Exit fullscreen mode

Step 4: Add Tailwind to Your Styles

Edit the CSS file src/style.css and add:

@import 'tailwindcss';
Enter fullscreen mode Exit fullscreen mode

Step 5: Import Tailwind CSS in main.ts

Check your src/main.ts and ensure your style.css is imported:

import { createApp } from 'vue'
import App from './App.vue'
import './style.css'

createApp(App).mount('#app')
Enter fullscreen mode Exit fullscreen mode

Step 6: Start Your Development Server

Run the Vite development server:

npm run dev
Enter fullscreen mode Exit fullscreen mode

That’s it! You’ve successfully set up Tailwind CSS v4 in a Vue 3 project using Vite. With this new streamlined setup, you can enjoy faster builds and an even smoother development experience.

Have you tried Tailwind CSS v4 yet? Share your thoughts in the comments! 🚀

Tiugo image

Fast, Lean, and Fully Extensible

CKEditor 5 is built for developers who value flexibility and speed. Pick the features that matter, drop the ones that don’t and enjoy a high-performance WYSIWYG that fits into your workflow

Start now

Top comments (7)

Collapse
 
oleksandr_pikush profile image
Oleksandr Pikush

it works

Collapse
 
tibering profile image
Tibering

├── @tailwindcss/postcss@4.1.4
├── @tailwindcss/vite@4.1.4
├── @vitejs/plugin-vue@5.2.3
├── autoprefixer@10.4.21
├── postcss@8.5.3
├── tailwindcss@4.1.4
├── vite@6.2.6
└── vue@3.5.13

it works

Collapse
 
v3nt profile image
v3nt

How do you configure it though?

Collapse
 
biscoff_underfield_b40840 profile image
Biscoff Underfield

garbage - doesn't work - just some ai pollution

Collapse
 
osalumense profile image
Stephen Akugbe

I'm sorry it didn't work for you, I only put this up after setting up a project in Vue3 with tailwind v4

Collapse
 
varma_sagi_82f557ba2d8a09 profile image
Varma Sagi

works

Collapse
 
esley_santana_868a75be670 profile image
Esley Santana

works

Image of Quadratic

Free AI chart generator

Upload data, describe your vision, and get Python-powered, AI-generated charts instantly.

Try Quadratic free

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, cherished by the supportive DEV Community. Coders of every background are encouraged to bring their perspectives and bolster our collective wisdom.

A sincere “thank you” often brightens someone’s day—share yours in the comments below!

On DEV, the act of sharing knowledge eases our journey and forges stronger community ties. Found value in this? A quick thank-you to the author can make a world of difference.

Okay