Vue 3, Vite, Tailwind CSS: A Step-by-Step Installation Guide

Prachi Shah
2 min readMar 10, 2024

--

Vue 3 brings a compelling framework for crafting modern web interfaces. To elevate your development experience further, consider using Vite, a lightning-fast build tool, alongside Tailwind CSS, a utility-first CSS framework. This blog post guides you through installing and setting up Vue 3, Vite, and Tailwind CSS, equipping you with a streamlined and powerful development environment.

Prerequisites:

Before we begin, ensure you have the following tools installed:

  • Node.js (latest LTS version recommended): Download and install it from the official website: https://nodejs.org/en
  • Code editor or IDE: Choose your preferred editor or IDE, such as Visual Studio Code, WebStorm, or any that suits your needs.

Installation

We’ll focus on local installation for better project management. Let’s create a project that leverages the power of Vue 3, Vite, and Tailwind CSS!

1. Node.js Setup:

If you haven’t already, install Node.js following the instructions on the official website. Verify the installation by running node -v and npm -v (or yarn -v) in your terminal or command prompt.

2. Vite Installation:

Open your terminal and navigate to your desired project directory. Use the following command to create a new Vue 3 project with Vite:

npm init -y vite@latest my-vue-tailwind-project

(Replace my-vue-tailwind-project with your preferred project name.)

3. Tailwind CSS Installation:

Navigate to your project directory:

cd my-vue-tailwind-project

Now, install Tailwind CSS and its dependencies using npm or yarn:

npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p

4. Tailwind Configuration:

Next, add the paths to all of your template files in your tailwind.config.js file.

JavaScript

/** @type {import('tailwindcss').Config} */
export default {
content: [
"./index.html",
"./src/**/*.{vue,js,ts,jsx,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}

This configuration tells Tailwind to scan your Vue components (src/**/*.vue) and the index.html file for CSS class usage.

5. Integrate Tailwind with Vite:

Add the @tailwind directives for each of Tailwind’s layers to your ./src/style.css file.

CSS

@tailwind base;
@tailwind components;
@tailwind utilities;

These directives import Tailwind’s base styles, components, and utility classes.

Running the Development Server:

Now, execute the following command to start the Vite development server with Tailwind CSS integration. Make sure to use tailwind classes to see the changes on the main page.

npm run dev

This launches the development server.

Conclusion

By following these steps, you’ve successfully installed and set up Vue 3, Vite, and Tailwind CSS. This powerful combination empowers you to create modern, responsive web applications with ease.

Explore Further:

Feel free to experiment with creating beautiful UIs using Tailwind’s utility classes and leverage the speed and efficiency of Vite while developing your Vue 3 applications!

--

--

Prachi Shah

I'm a Software Engineer specializing in Laravel backend development. I love building strong and scalable web applications. Learning new things motivates me.