@jerad
To install Tailwind CSS in a Vue.js 3 + Vite project, you can follow these steps:
- Create a new Vue.js 3 project with Vite by running the following command in your terminal:
- Choose the Vue template when prompted.
- Install Tailwind CSS and its dependencies by running the following command in your terminal:
1
|
npm install -D tailwindcss@latest postcss@latest autoprefixer@latest
|
- Initialize a Tailwind configuration file by running the following command in your terminal:
1
|
npx tailwindcss init -p
|
- Create a new CSS file to include Tailwind CSS styles. For example, you can create a styles.css file in the src directory of your project.
- Import Tailwind CSS styles in the styles.css file:
1
2
3
|
@tailwind base;
@tailwind components;
@tailwind utilities;
|
- Import the styles.css file in your main.js file to include Tailwind CSS styles in your Vue components:
1
2
3
4
5
|
import { createApp } from 'vue'
import App from './App.vue'
import './styles.css'
createApp(App).mount('#app')
|
- Configure PostCSS to use Tailwind CSS by creating a postcss.config.js file in the root of your project with the following content:
1
2
3
4
5
6
|
module.exports = {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
|
That's it! Tailwind CSS should now be successfully installed and configured in your Vue.js 3 + Vite project. You can start using Tailwind CSS classes in your Vue components to style your application.