DEV Community

Awan
Awan

Posted on

Install TailwindCSS di Vue 3

  1. Pertama install tailwind dengan dependensi-nya dengan perintah berikut.
npm install -D tailwindcss postcss autoprefixer
Enter fullscreen mode Exit fullscreen mode

Install TailwindCSS

2.Lalu buat file confignya dengan perintah berikut

npx tailwindcss init -p
Enter fullscreen mode Exit fullscreen mode

Generate tailwind Config

3.Lalu lakukan config tailwind sebagai berikut di file tailwind.config.js
Ubah

content: [],
Enter fullscreen mode Exit fullscreen mode

Menjadi

content: [
    "./index.html",
    "./src/**/*.{vue,js,ts,jsx,tsx}",
  ],
Enter fullscreen mode Exit fullscreen mode

4.Buatlah sebuah file src/assets/css/tailwind.css lalu isikan sebagai berikut

@tailwind base;
@tailwind components;
@tailwind utilities;
Enter fullscreen mode Exit fullscreen mode

5.Import tailwind.css di file main.js dengan code berikut

import '@/assets/css/tailwind.css'; 
Enter fullscreen mode Exit fullscreen mode

Import tailwind.css

6.Buka file App.vue dan ubah semua isinya dengan code berikut

<template>
  <h1 class="text-3xl font-bold underline">
    Hello world!
  </h1>
</template>

<script>

export default {
  name: 'App',
}
</script>
Enter fullscreen mode Exit fullscreen mode

7.Jalankan perintah berikut

npm run serve
Enter fullscreen mode Exit fullscreen mode

Run VueJS di Terminal

8.Lalu buka di browser, maka hasilnya seperti berikut
VueJS Running

SurveyJS custom survey software

Simplify data collection in your JS app with a fully integrated form management platform. Includes support for custom question types, skip logic, integrated CCS editor, PDF export, real-time analytics & more. Integrates with any backend system, giving you full control over your data and no user limits.

Learn more

Top comments (0)

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay