Eastly Install Tailwind CSS in Laravel 9?

About Us:

We are from free coder. We are a group of web developers who are passionate about web development. You can learn from us php, laravel, node js, vue js, react js and many other topic on web developement.
we are very happy to help you.
free coder

Today what you are going to learn:

Hi Brother,

In this post, we will learn laravel 9 install tailwind CSS. I explained simply step by step install tailwind laravel 9. In this article, we will implement a how to install tailwind css in laravel 9. let’s discuss about how to install tailwind in laravel 9.

Tailwind is a CSS framework like bootstrap. using tailwind css use can create responsive website design. In this post, i will give three ways to install tailwind css in your laravel application. you can see the below list:

1) Install Tailwind CSS using npm

2) Install Tailwind CSS using Breeze

3) Install Tailwind CSS using Jetstream

So, let's follow the below step by step to install tailwind CSS in laravel application.

1) Install Tailwind CSS using npm

In this step, I will give you a list of steps using the npm command. so let's follow it.

Lesson 1: Install Laravel

If have not already set up of laravel application then you can run the below command to get a fresh laravel app:

composer create-project laravel/laravel lesson-app

Lesson 2: Install Tailwind CSS

Let's install tailwind CSS with dependency and create a tailwind.config.js file. so run the below command:

npm install -D tailwindcss postcss autoprefixer

npx tailwindcss init

Lesson 3: Configure Template Path

Hello Brother, open the tailwind.config.js file and add the files path there:

tailwind.config.js

module.exports = {

content: [

"./resources/**/*.blade.php",

"./resources/**/*.js",

"./resources/**/*.vue",

],

theme: {

extend: {},

},

plugins: [],

}

Lesson 4: Add Tailwind with Laravel mix

Hello Brother, open the webpack.mix.js file and add lines there:

webpack.mix.js

const mix = require('laravel-mix');

/*

|--------------------------------------------------------------------------

| Mix Asset Management

|--------------------------------------------------------------------------

|

| Mix provides a clean, fluent API for defining some Webpack build steps

| for your Laravel applications. By default, we are compiling the CSS

| file for the application as well as bundling up all the JS files.

|

*/

mix.js("resources/js/app.js", "public/js")

.postCss("resources/css/app.css", "public/css", [

require("tailwindcss"),

]);

Lesson 5: Add Tailwind CSS in the app.css file

Hello Brother, open the app.css file and add lines there:

resources/css/app.css

@tailwind base;

@tailwind components;

@tailwind utilities;

Lesson 6: Install npm and Build

Run "npm install" command and then build it with "npm run watch" command:

npm install

Build npm process:

npm run watch

Lesson 7: Use Tailwind CSS in App

Now, you can use Tailwind CSS in your blade file as below:

resources/views/welcome.blade.php

<!doctype html>

<html>

<head>

<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<link href="{{ asset('css/app.css') }}" rel="stylesheet">

</head>

<body>

<div class="container mx-auto px-10">

<h1 class="text-3xl font-bold underline">

How to Install Tailwind CSS in Laravel - ItSolutionStuff.com

</h1>

<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod

tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,

quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo

consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse

cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat ncupidatat non

proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>

</div>

</body>

</html>

Let's see below output:

2) Install Tailwind CSS using Breeze

In this step, i will give you list of steps using npm command. so let's follow it.

Lesson 1: Install Laravel

If have not already setup of laravel application then you can run below command to get fresh laravel app:

composer create-project laravel/laravel lesson-app

Lesson 2: Install Breeze

Let's run bellow command to install laravel breeze package by bellow command:

composer require laravel/breeze --dev

Next you have to install laravel breeze for simple auth scaffolding. so let's run bellow command:

php artisan breeze:install

Now let's run bellow command for install npm:

npm install && npm run dev

That's it. you will have setup on tailwind css based.

3) Install Tailwind CSS using Jetstream

In this step, i will give you list of steps using npm command. so let's follow it.

Lesson 1: Install Laravel

If have not already setup of laravel application then you can run below command to get fresh laravel app:

composer create-project laravel/laravel lesson-app

Lesson 2: Install Jetstream

Now, in this step, we need to use composer command to install jetstream, so let's run bellow command and install bellow library.

composer require laravel/jetstream

Lesson 3: Create Auth with Livewire:

now, we need to create authentication using bellow command. you can create basic login, register and email verification. if you want to create team management then you have to pass addition parameter. you can see bellow commands:

php artisan jetstream:install livewire

OR

php artisan jetstream:install livewire --teams

Now, let's node js package:

npm install

let's run package:

npm run dev

That's it. you will have setup on tailwind css based.

thank you very much for following up with me.

Recent Posts

Related Posts