DEV Community

Cover image for How to start a project with NuxtJS 3 and Tailwindcss ?
Yann
Yann

Posted on

How to start a project with NuxtJS 3 and Tailwindcss ?

Nuxt.js is a framework for building universal Vue.js applications. It is based on Vue.js, a popular JavaScript library for building web user interfaces, and adds a number of additional features to make it easier to build universal applications.

To start a project with Nuxt.js and Tailwind CSS, you will first need to install the required dependencies.

To install Nuxt.js, you can use the following command :

npx nuxi init <project-name>
Enter fullscreen mode Exit fullscreen mode

To install Tailwind CSS, you can use the following command :

yarn add tailwindcss postcss autoprefixer
npx tailwindcss init
Enter fullscreen mode Exit fullscreen mode

Next, you will need to configure Nuxt.js to use Tailwind CSS. To do this, you will need to add the following to your nuxt.config.js file :

// https://v3.nuxtjs.org/api/configuration/nuxt.config
export default defineNuxtConfig({
css: ['~/assets/css/main.css'],
  postcss: {
    plugins: {
      tailwindcss: {},
      autoprefixer: {},
    },
  },
})
Enter fullscreen mode Exit fullscreen mode

This will configure Nuxt.js to include the tailwind.css file in your project's build.

Create ./assets/css/main.css :

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

Finally, you will need to create a tailwind.config.js file in the root of your project and configure it to use the styles that you want.

For example, you might add the following to your tailwind.config.js file to use the default styles provided by Tailwind CSS:

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./components/**/*.{js,vue,ts}",
    "./layouts/**/*.vue",
    "./pages/**/*.vue",
    "./plugins/**/*.{js,ts}",
    "./nuxt.config.{js,ts}",
    "./app.vue",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}
Enter fullscreen mode Exit fullscreen mode

With these steps, you should now have a working Nuxt.js project with Tailwind CSS configured. You can now start building your project!

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay