Favourite List
Nothing Added.

Create Your First Project with Tailwind CSS

Tailwind CSS, a Modern CSS framework developed by the Tailwind project. It can work with Tailwind Cli and CDN.Tailwind CSS can best be described as a “utility-first” framework. Utility-first frameworks are composed of small, simple classes that can be applied to elements to create a user interface. 

Tailwind CSS


Tailwind offers predesigned widgets to build a site from scratch while Bootstrap comes with a set of pre-styled responsive design. As you go through this tutorial, you can make your own project with tailwind css. If you are new to Tailwind CSS and want to Learn, this blog will help you with easy explanination.

Setup Tailwind CSS

Tailwind can be used as Bootstrap with CDN. For that you need to add java script to your HTML document before colosing headtag . CDN is designed for development purposes only, and is not the best choice for production. IN this tutorial we will install Tailwind Client.

Tailwind CDN [Not Recommended]

Add the Play CDN script tag to the <head> of your HTML file, and start using Tailwind’s utility classes to style your content.
<script src="https://cdn.tailwindcss.com"></script>

Tailwind CDN

Tailwind CLI Setup [Recommended]

The simplest and fastest way to get up and running with Tailwind CSS from scratch is with the Tailwind CLI tool. For that we need nodejs and npm. Windows user can download and install nodejs.org on this link. 

Linux (Ubuntu) user simply run this command.
sudo apt install nodejs npm -y

We also need a code editor. For that download visual studio code and install it. After installation complete click extension and install 'Tailwind CSS IntelliSense' and Live server. For better experience (optional) you can also install this extension pack. If nothing goes wrong than our Tailwind CLI installation complete.

Create Your First Tailwind Project

Create a new Folder with your Project name and Open it on Terminal. Windows user simply open the folder, on addressbar of file explorer type 'cmd' and hit 'Enter'. Now let's initialize our project folder with npm. Run below command and provide Project Name with lower case as well as description , version author etc.

npm init

Now let's bind our project with Tailwind CSS. For that run this command.

npx tailwindcss init

It will generate a folder and create a file called tailwind.config.js. Open this file in vs code and add this line  inside  content[]; 

"./src/**/*.{html,js}"
Tailwind Conf

Now create a folder 'src' and inside of this folder create 'input.css' 'index.html' . Now open input.css and add this code.

@tailwind base;

@tailwind components;

@tailwind utilities;

Tailwind CSS Compiler

Now time to setup compiler that watch and complie code instantly. For that add below line into package.json script keys value field.

    "compile" : "tailwindcss -i ./src/input.css -o ./dist/output.css --watch",
Compiler



Now, Let's add css file link to our index page. Here is a our sample index page codes. Copy and paste it.

 <!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../dist/output.css">
<title>Hello Tailwind</title>
</head>
<body>
<div class="bg-indigo-500 w-100">
Hi,Mr Orkitt
</div>
</body>
</html>

Well, Now compile and run our code, On terminal run this commands.

npm run compile

After compiled successfully, you can now open index page with Live Server and see the magic. Thank You.

Wrapping Up

After going through this tutorial, you can now make your own project with tailwind css and  Learn to use the CSS framework Tailwind. In this serise of course you will learn how to build websites and apps with Tailwind CSS. In this course we'll discuss the different elements in Tailwind, and how they work together to create large-scale, engaging web applications on any device. So keep tuning with Orkitt. Happy coding.
Next Post Previous Post
Feels like
No Comment
Add Comment
comment url