Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tailwind CSS Tutorial
  • Tailwind Interview Questions
  • Tailwind Layout
  • Tailwind Flexbox
  • Tailwind Grid
  • Tailwind Alignment
  • Tailwind Spacing
  • Tailwind Sizing
  • Tailwind Typography
  • Tailwind Backgrounds
  • Tailwind Borders
  • Tailwind Effects
  • Tailwind Filters
  • Tailwind Tables
  • Tailwind Transitions and Animation
  • Tailwind Transforms
  • Tailwind Interactivity
  • CSS Frameworks
  • Web Technology
Open In App
Next Article:
Getting Started with Tailwind CSS
Next article icon

Getting Started with Tailwind CSS

Last Updated : 01 Apr, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Tailwind CSS is a popular utility-first CSS framework that can help you create modern and responsive web designs quickly and easily. While you can download and use Tailwind CSS locally in your project, you can also use it with a CDN (Content Delivery Network) in your HTML project. Basically Tailwind CSS provides the CSS classes that has some styling involved by adding those classes into your code or project we can inherit or add those styling into out project. This helps us to create a project without help of vanilla CSS.

Getting-started-with-Tailwind-CSS-copy

This allows you to include the necessary CSS and JS files from the CDN instead of downloading them, which can help improve your website's loading time and performance. This article is a beginner's guide to Tailwind CSS in React projects, covering installation, basic concepts, and usage examples.

Pre-requisites

  • HTML
  • CSS

Basics of Tailwind CSS

The basic CSS that we must know so that we can implement it to our daily projects are these:

  • Tailwind CSS height
  • Tailwind CSS Width
  • Tailwind CSS Overflow
  • Tailwind CSS Flex
  • Tailwind CSS Display
  • Tailwind CSS Border Radius
  • Tailwind CSS Background Image
  • Tailwind CSS Background Color
  • Tailwind CSS List Style Type
  • Tailwind CSS Box Shadow
  • Tailwind CSS Position

How to use Tailwind CSS?

Using CDN Link:

Using Tailwind CSS via CDN link allows you to quickly include Tailwind CSS in your HTML file without the need for any installation or setup. Simply add the Tailwind CSS CDN link to the <head> section of your HTML file, and you can start using Tailwind CSS utility classes immediately.

CDN link:

<script src="https://cdn.tailwindcss.com"></script>

Using Package Manager:

To use Tailwind CSS in your HTML project via a package manager like npm, you need to install Tailwind CSS as a dependency. After installation, you can include Tailwind CSS in your HTML file using a <link> tag. This approach allows for customization of Tailwind CSS configuration and tree shaking to optimize the final CSS bundle size

Step 1: Initialize a new HTML project or navigate to your existing project directory.

mkdir my-tailwind-project
cd my-tailwind-project

Step 2: Initialize a new npm project (if you haven't already):

npm init -y

Step 3: Install Tailwind CSS and its dependencies:

npm install tailwindcss postcss-cli autoprefixer

Step 4: Create a tailwind.config.js file to customize Tailwind (optional):

npx tailwindcss init

Step 5: Create a postcss.config.js file to process your CSS with Tailwind:

// postcss.config.js

module.exports = {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
]
}

Example: Create your HTML file (e.g., index.html) and include Tailwind classes:

HTML
<!DOCTYPE html> <html>  <head>     <meta charset="UTF-8" />     <meta name="viewport" content="width=device-width,                                    initial-scale=1.0" />     <script src="https://cdn.tailwindcss.com"></script>     <script>         tailwind.config = {             theme: {                 extend: {                     colors: {                         clifford: "#da373d",                     },                 },             },         }     </script> </head>  <body>     <h1 class="text-3xl font-bold                underline text-clifford">           Hello world!       </h1> </body>  </html> 


Output: Open the HTML file in a browser to See the Below Output

tailwind-ezgifcom-video-to-gif-converter-(1)
HTML with Tailwind CSS

Advantages of Using Tailwind CSS

  • Rapid Development: Speed up your development workflow with pre-built utility classes.
  • Flexibility: Customize styles without leaving your HTML file, offering unparalleled flexibility.
  • Scalability: Easily scale your projects by reusing utility classes for consistent styling.
  • Responsive Design: Tailwind provides built-in classes for responsive design, ensuring your application looks great on any device.

How to Use Tailwind CSS in a Project?

  • Installation: Install Tailwind CSS via npm or yarn.
  • Configuration: Create a configuration file to customize Tailwind according to your project's needs.
  • Integration: Integrate Tailwind CSS into your build process or use it within your preferred build tools.

Next Article
Getting Started with Tailwind CSS

B

banu3513
Improve
Article Tags :
  • Web Technologies
  • CSS
  • Tailwind CSS

Similar Reads

    Tailwind CSS Min-Width
    This class accepts lots of values in tailwind CSS in which all the properties are covered in class form.  It is the alternative to the CSS min-width property. This class is used to define the minimum width of an element. The value of the width cannot be less than the value of the min-width. If the c
    1 min read
    Install & Setup Tailwind CSS with Next.js
    Tailwind is a popular utility first CSS framework for rapidly building custom User Interfaces. It provides low-level classes, those classes combine to create styles for various components. You can learn more about Tailwind CSS here.  Next.js: Next.js is a React-based full-stack framework developed b
    2 min read
    What is Tailwind CSS ?
    Tailwind CSS is a CSS framework that helps developers in the rapid designing of the web without shifting back and forth between different pages for HTML and CSS. Tailwind CSS doesn't come with pre-designed components, rather it provides set of utility classes that can be used to style HTML elements
    3 min read
    What is Tailwind CSS?
    Tailwind CSS is the utility-first CSS framework that provides the low-level utility classes that can be used to build custom designs, without the need to write the traditional CSS. Unlike traditional frameworks like Bootstrap, Tailwind CSS does not provide predefined components like buttons or cards
    5 min read
    Tailwind CSS Width
    This class accepts lots of values in tailwind CSS in which all the properties are covered as in class form. It is the alternative to the CSS Width Property. This class is used to set the width of the text, images. The width can be assigned to the text and images in the form of pixels(px), percentage
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences