×

Tailwind CSS Installation

Here, we will discuss the installation method of Tailwind CSS using two strategies discussed as follows:

Strategy 1: Install Tailwind through npm

Step 1: npm init - y

Step 2: npm install tailwindcss

Tailwind CSS Installation
Tailwind CSS Installation

Step 3: Use the @tailwind mandate to infuse Tailwind's base, parts, and utility styles into your CSS document, as shown below:

@tailwind base;

@tailwind component;

@tailwind utilities;

Tailwind CSS Installation

Step 4: npx tailwindcss init
This is utilized to make a config document to modify the plans. It is a discretionary advance.

Step 5: npx tailwindcss construct styles.css - o output.css
This order is utilized to compile style.css is the document that must be compiled and output.css is the record on which it must be compiled. If the document output.css isn't made before then it will automatically be made.

Strategy 2: Utilizing Tailwind through CDN.

<- - - add it to the head segment of the html file- - ->

<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet">

Tailwind CSS Installation
  • However, there are a few constraints when CDN is used.
    Some of them are:
    • Customize Tailwind's default theme can't be utilized
    • Orders like @apply, @variants, and so forth can't be utilized
    • Can't introduce outsider modules (third-party plugins)
  • Below browsers are supported by tailwind CSS:
    • Google Chrome
    • Firefox
    • Safari
    • Microsoft Edge

Let’s consider an example.

Example / code of html:

<!-- Write HTML code here -->
<!DOCTYPE html>
<html lang="en" dir="ltr">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport"
      content="width=device-width,
          initial-scale=1.0" />
    <title>Tailwind CSS</title>
    <link rel="stylesheet"
      href="./style.css" />
  </head>
  <body>
    <!-- font size -->
    <h1 class="text-lg">Font Size- Large</h1>
    <!-- font weight -->
    <h1 class="font-bold">Fond Weight- Bold</h1>
    <!-- Typography -->
    <h1 class="tracking-widest">Spacing Between Words</h1>
    <!-- Transform -->
    <h1 class="uppercase">Uppercase Word</h1>
    <!-- line height align color background
      width padding margin border opacity shadow-->
    <div class="leading-9 text-right
          text-black -650
          bg-yellow-500 w-1/2 h-1/3 p-5 my-10
          border-t-2
          border-solid
          border-pink-500
          opacity-40
          shadow-2xl">
      
<p> Tutorial And Example </p>


    </div>
    <!-- focus pseudo class -->
    <input class="border focus:border-blue-500
          focus:outline-none p-5 m-5
          placeholder-red-500"
      type="text"
      name=""
      value=""
      placeholder="name" />
    <!-- layout -->
    <div class="md:flex md:flex-wrap m-5">
      <div class="bg-orange-500
            p-5 md:w-1/3
            md:bg-red-600">
      Tutorial And Example
    </div>
      <div class="bg-blue-500 p-5 md:w-1/3">
      Tutorial And Example
    </div>
      <div class="bg-pink-500 p-5 md:w-1/3">
      Tutorial And Example
    </div>
    </div>
  </body>
</html>

The output for the above code is as follows:

Tailwind CSS Installation

Related Topics

Tailwind CSS Order

One of the best features of Tailwind CSS is the Order class, which allows us to order flex and grid objects according to our needs. There are several different order...

2 minutes read.

Tailwind CSS Grid Template Columns

In tailwind CSS, this class accepts multiple values, and all of the properties are covered in class form. It's the CSS grid-template-columns property's replacement. It's used to specify the number...

2 minutes read.

Tailwind CSS Margin

The margin class accepts a large number of values, and all of the properties are covered in the same way they are in the class form. It's a replacement for...

6 minutes read.

Tailwind CSS Min-Width

In tailwind CSS, this class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS min-width property. This...

1 minute read.

Tailwind CSS Box Shadow

The Tailwind CSS Box Shadow class accepts a lot of value, and all of the properties are covered in class form. We may control the box-shadow of an element by...

2 minutes read.

Tailwind CSS Top / Right / Bottom / Left

In tailwind CSS, these classes take a variety of values and cover all of the characteristics in the class form. These are the CSS Top/Right/Bottom/Left properties' replacements. These classes are...

4 minutes read.

Tailwind CSS Z-index

The tailwind CSS framework is a CSS utility framework that provides classes for managing HTML content with CSS. Tailwind CSS simplifies our design process and makes it responsive across numerous...

4 minutes read.

Tailwind CSS Justify Self

The class form goes over the various properties. It's a replacement for the CSS justify-self attribute. This class is used to describe the alignment of content’s position in a CSS...

4 minutes read.

Tailwind CSS Opacity

This class accepts a lot of value, and all of the properties are covered in class form. We can change the opacity of any element by using this class. The...

1 minute read.

Tailwind CSS Fill

The CSS Fill class accepts a lot of value, and all of the properties are covered in class form. It is a presentation attribute that controls how an SVG shape's...

1 minute read.

Tailwind CSS Grid Auto Flow

In tailwind CSS, this class accepts multiple values, and all of the properties are covered in class form. It is a CSS alternative. The grid-auto-flow property is used in Tailwind...

4 minutes read.

Tailwind CSS Align Content

In Tailwind CSS, this class accepts a wide range of values. It's a replacement for the CSS Align Content feature. This class is used to modify the flex-wrap property's behavior....

5 minutes read.

Tailwind CSS Flex Wrap

CSS flexbox is an important component for frontend development. It is a front-end development alternative to the CSS flex-wrap Property. Note: You must include the flex class in your element before...

4 minutes read.

Tailwind CSS Space Between

In tailwind CSS, this class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Space Between property....

4 minutes read.

Tailwind CSS Place Content

This class accepts a wide range of values. It's a replacement for the CSS Place Content property. This class is used to manage how information is justified while still being...

5 minutes read.

Tailwind CSS Grid Row Start / End

In tailwind CSS, this class takes several values. All of the attributes are covered in the form of a class. In CSS, it's an alternative to the grid-row attribute. It's...

4 minutes read.

Tailwind CSS Object Fit

It acknowledges more than one value in tailwind CSS. Every one of its properties is covered as in class form. It is the option in contrast to the CSS object-fit...

4 minutes read.

Tailwind CSS Box Sizing

Tailwind CSS Box sizing class acknowledges more than one worth in tailwind CSS. Each property is shrouded as a class structure. It is an option in contrast to the CSS...

2 minutes read.

Tailwind CSS Float

The float class acknowledges more than one worth (value) in tailwind CSS. It is an option in contrast to the CSS float property. The float class characterizes the progression of...

4 minutes read.

Tailwind CSS Place Self

The tailwind CSS Place self class accepts a wide range of values. It's a replacement for the CSS Place Items property. This class is used to manage how a single...

4 minutes read.