×

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 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 Clear

This class acknowledges more than one worth in tailwind CSS. Every one of the properties is canvassed as in class form. It is an option in contrast to the CSS...

5 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 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 Align Items

In tailwind CSS, this class accepts a wide range of values. It's a replacement for the CSS Align Items attribute. This class is used to align things within the flexible...

5 minutes read.

Tailwind CSS Flex Grow

CSS flexbox is an important element for frontend development; there are two flex-grow options in Tailwind CSS, and all attributes are covered in class form. It is an alternative to...

3 minutes read.

Tailwind CSS Container

In Tailwind CSS, a compartment is utilized to fix the maximum width (max-width) of a component to match the min-width of the breakpoint. It comes exceptionally convenient when content must...

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 Position

The position class acknowledges more than one value in tailwind CSS. It is an option in contrast to the CSS Position property. This class is utilized for controlling how an...

5 minutes 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 Overflow

The overflow class acknowledges more than one value in Tailwind CSS. It is an option in contrast to the CSS Overflow property. This overflow is for controlling how element content...

9 minutes read.

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 Step...

2 minutes read.

Tailwind CSS Max-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 max-width property. This...

3 minutes read.

Tailwind CSS Stroke

This class accepts a lot of value, and all of the properties are covered in class form. It's the stroke class that goes on top of the SVG element. Stroke...

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 Grid Template Rows

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

2 minutes read.

Tailwind CSS Min-Height

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-Height Property. It...

2 minutes read.

Tailwind CSS Flex

CSS flexbox is an important component for frontend development. There are four flex options in Tailwind CSS, and all of the attributes are covered in class form. It's a front-end...

6 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 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.