tailwind-css-guide

1.First we create our next.js file (in the example we create an app called cat-app)

Screenshot 2022-03-14 at 11 19 24

code source = npx create-next-app@latest cat-app cd cat-app


2.We configure tailwind e we initialise the tailwind config file

Screenshot 2022-03-14 at 11 20 47

code source = npm install -D tailwindcss postcss autoprefixer npx tailwindcss init -p


##importan If you get an error about babel compiler

  • create a babelrc file with no extension and add the following line of code
Screenshot 2022-03-14 at 11 27 38

code source = { "presets": ["next/babel"], "plugins": [] }

  • replace the .eslintrc.json file content with this line of code
Screenshot 2022-03-14 at 11 31 14

source code = { "extends": ["next/babel","next/core-web-vitals"] }


3. Copy this code inside the tailwind.config.js file Screenshot 2022-03-14 at 11 24 24

code source = module.exports = { content: [ "./pages//*.{js,ts,jsx,tsx}", "./components//*.{js,ts,jsx,tsx}", ], theme: { extend: {}, }, plugins: [], }


  1. On global.css file add the following tailwind structure and basic css
Screenshot 2022-03-14 at 11 32 52

source code = @tailwind base; @tailwind components; @tailwind utilities;

html, body { padding: 0; margin: 0; }

a { color: inherit; text-decoration: none; }

  • { box-sizing: border-box; }

  1. Delete unnecessary files
Screenshot 2022-03-14 at 11 35 44

6.Clean the home page to look like this

Screenshot 2022-03-14 at 11 37 20

source code = export default function Home() { return (

The Cat App

) }


7.Add some image on your public folder and import the images using Image components in your home page

source code =

import Image from "next/image" import cat1 from "../public/images/cat1.gif" import cat2 from "../public/images/cat2.gif" import cat3 from "../public/images/cat3.gif"

export default function Home() { return (

The Cat App

Picture of Cat1
) }


  1. Here an example of extra css style added

source code =

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

a { color: inherit; text-decoration: none; }

  • { box-sizing: border-box; padding: 0; margin: 0; }

body { background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab); background-size: 400% 400%; animation: gradient 15s ease infinite; }

@keyframes gradient { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }


Guide complete

Top categories

tailwind logo

Need a Tailwind website built?

Hire a professional TailwindCSS developer today.
Loading Svelte Themes