DEV Community

Cover image for Getting started with TailwindCSS
v1shalm
v1shalm

Posted on

1

Getting started with TailwindCSS

Tailwind CSS can be used to make websites in the fastest and the easiest way.

Tailwind CSS is basically a utility-first CSS framework for rapidly building custom user interfaces. It is a highly customizable, low-level CSS framework that gives you all of the building blocks you need to build bespoke designs without any annoying opinionated styles you have to fight to override. The beauty of this thing called tailwind is it doesn’t impose design specification or how your site should look like, you simply bring tiny components together to construct a user interface that is unique. What Tailwind simply does is take a ‘raw’ CSS file, processes this CSS file over a configuration file, and produces an output.

Installation
In this project, we will install Tailwind CSS via Node Package Manager (npm), but you could also use the CDN. If you choose the latter approach, you will not be able to use some features like extracting custom CSS classes. But if you just want to give it a spin, then go for it.

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

To install Tailwind, we will first create a folder:

$ mkdir mytailwindcsssite
Now, change to the newly created folder and initialise npm to install Tailwind:

$ cd mytailwindcsssite
$ npm init -y

After initialising npm in the folder, a package.json file will be created. Now we can install the tailwindcss package easily by running the following command:

$ npm install tailwindcss

Adding Tailwind to the project

The next step is to add Tailwind to our project. For that, we will create a file called src/styles.css in which we will inject all three Tailwind directives to import base, components, and utilities styles:

@tailwind base;
@tailwind components;
@tailwind utilities;

You could also add a Tailwind configuration file within the project that lets you create your own CSS classes or import fonts via the @import rule. To install the tailwindcss configuration file, run the following command:

$ npx tailwindcss init

This will create a new file called

tailwind.config.js

Tiugo image

Modular, Fast, and Built for Developers

CKEditor 5 gives you full control over your editing experience. A modular architecture means you get high performance, fewer re-renders and a setup that scales with your needs.

Start now

Top comments (0)

AWS Security LIVE! Stream

Go beyond the firewall

There's more to security than code. Explore solutions, strategies, and the full story on AWS Security LIVE!

Learn More

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay