As you advance as a developer, you are more likely to use technologies that help you do more by writing less code. A solid frontend framework like Tailwind CSS is one way to accomplish that.
In this article, we’ll learn about Tailwind CSS — a CSS framework that aids in building and designing web pages. We’ll start by explaining how to install and integrate Tailwind CSS in your project, see some practical applications, and also how you can create your custom styles and plugins.
Excited? Let’s begin!
What Is Tailwind CSS?
Tailwind CSS is a utility-first CSS (Cascading Style Sheets) framework with predefined classes that you can use to build and design web pages directly in your markup. It lets you write CSS in your HTML in the form of predefined classes.
We’ll define what a framework is and what we mean by “utility-first CSS” to help you better understand what Tailwind CSS is all about.
What Is a Framework?
As a general programming term, a framework is a tool that provides reusable and ready-made components built from the features of an already existing tool. The overall purpose of creating frameworks is to increase development speed by doing less work.
Now that we’ve established the meaning of a framework, it should help you understand that Tailwind CSS is a tool built upon CSS features. All the framework’s functionalities were derived from CSS styles composed as classes.
What Is a Utility-First CSS Framework?
When we say utility-first CSS, we refer to classes in our markup (HTML) with predefined functionalities. This implies that you only have to write a class with predefined styles attached to it, and those styles will be applied to the element.
In a case where you are working with vanilla CSS (CSS without any framework or library), you would first give your element a class name and then attach different properties and values to that class, which will, in turn, apply styling to your element.
We’ll show you an example. Here, we’ll create a button with rounded corners and a text that says “Click me.” This is what the button will look like:
We’ll first do this using vanilla CSS, and then using utility classes available in Tailwind CSS.
With Vanilla CSS
<button class="btn">Click me</button>
We’ve given button tags the class
btn, which will be styled using an external stylesheet. That is:
This article was written by Ihechikara Abba and originally published on Blog – Kinsta®.