Sitemap

Tailwind CSS

3 min readOct 29, 2021

--

Press enter or click to view image in full size

Tailwind CSS is a post CSS plugin that is used to style a webpage. This can be used with basic HTML or with front-end frameworks like React, Vue or Angular. Tailwind CSS has had rising popularity over the recent months and is being widely used to style websites.

According to the official website of tailwindcss, it is described as a utility first framework packed with classes. The main point of Tailwind CSS is that you can style your HTML website right in the HTML file. This is quite similar for the front-end frameworks as well. This can be done by using a class in the element you wish to style.

An example of a class that can be used to style a particular element can be:

Press enter or click to view image in full size

The following HTML code would produce the image shown below as shown in the official tailwind CSS website. Furthermore, the classes used to style the components are shown in the image above and is quite similar to plain CSS.

Press enter or click to view image in full size

This is an example shown in the tailwind CSS website and is not an example made by me.

How to get started with Tailwind CSS?

Setting up tailwind CSS can be a bit confusing, but it's worth the effort.

Firstly tailwind CSS must be installed using the command in the terminal :

npm install tailwindcss

After it is installed, create a CSS file and add the following code into it:

Press enter or click to view image in full size

I have named my file tailwind.css, you can use any name.

Get Vikum Dabare’s stories in your inbox

Join Medium for free to get updates from this writer.

@tailwind base;

@tailwind components;

@tailwind utilities;

Once that is done run the following command in the terminal :

npx tailwind init

This will generate a file, nextly we should add the post CSS file. This can be done by using the following command in the terminal:

npm install postcss-cli autoprefixer

When the installation is completed run the following command in the terminal:

touch postcss.config.js

A file will be generated, add this code to the plugins:

Press enter or click to view image in full size

Great, all the hard work is done. We just need to run the file.

In the terminal use, the following commands after the previous one is executed:

npx postcss tailwind.css -o public/style.css

npm run build

If you did follow the steps shown above you should have a tailwindcss development environment. Installation for frameworks can be found here.

The tailwindcss documentation can be found here.

--

--

Vikum Dabare
Vikum Dabare

Written by Vikum Dabare

Self-taught full stack developer (MERN stack). I love writing blogs and coding :) Catch me on discord: iiTz Vikum#8711 or email: vikumdabare@gmail.com