- Consulting
- Training
- Partners
- About Us
x
Tailwind CSS is the most popular utility-first CSS framework for rapidly building custom user interfaces for the web. It is a highly customizable collection of low-level CSS utility classes written in PostCSS destined to be customized using JavaScript.
The first release of Tailwind CSS happened on the 1st of November 2017 on GitHub as an open-source project. Initially, only a side project for Adam Wathan helped him with some of his projects. Still, it became a fully-fledged and popular CSS framework with a new utility-first methodology.
Step 1: Create a new project folder and go inside your directory by using the following command:
1 |
$ mkdir tailwind-sample-01 |
Step 2: Initialize a new project that will create a new package.json file by writing the following command:
1 |
$ npm init -y |
Step 3: The first dependency which needs to be added to the project is the Tailwind CSS package. The following command is used for installation:
1 |
$ npm install tailwindcss |
or
1 |
$ yarn add tailwindcss |
Step 4: The next step is to add Tailwind to the project’s CSS. Create a new file css/styles.css and insert the @tailwind directive.
1 2 3 |
@tailwind base; @tailwind components; @tailwind utilities; |
Step 5: Next step is to add a Tailwind configuration file by running the following command. The generated file will be present in your root directory (tailwindcss.config.js)
1 2 3 4 5 6 7 8 |
module.exports = { theme: { extend: {}, }, variants: {}, plugins: [], } |
Step 6: Tailwind CSS requires a build process that processes CSS files and makes sure that the Tailwind CSS code is inserted according to the directives used and the Tailwind configuration in place.
In addition, we will also use a plugin which is called autoprefixer
1 |
$ npm install postcss-cli autoprefixer |
Step 7: With those packages installed let’s create a PostCSS configuration file in the project directory
1 |
touch postcss.config.js |
Step 8: Inside this file, we have to add the following code
1 2 3 4 5 6 |
module.exports = { plugins: [ require('tailwindcss'), require('autoprefixer'), ] } |
Step 9: Finally, the last step is to add a script inside our package.json file
1 |
"build": "postcss css/styles.css -o build/styles.css" |
Step 10: To run this script inside your ide terminal run
1 |
npm run build |
This script will ensure that whatever tailwind classes we are using, we are converting them into original CSS. So, now, inside our build folder, just create an index.html file and link our styles.css file with that. So, whenever we make any changes, those changes are reflected in the user.
Finally, install a live server extension from the extension bar of your preferred
Finally, our project will start running on some ports using the live server application
When a browser displays a document, it must combine its content with its style information. It processes the paper in two phases:
The browser displays the contents of the DOM.
I hope this blog helped you understand what Tailwind CSS is, how it works, and the advantages it can have over other CSS Frameworks when it comes to building user interfaces fast and efficiently.
CloudThat is also the official Microsoft Gold Partner, AWS Advanced Consulting Partner, and Training partner helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.
Using three-way we can integrate CSS on a web page
Voiced by Amazon Polly |
Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!
Bhuvi Bajpeyee
May 16, 2022
It’s quite helpful. Thank you
Click to Comment