How to use Ant Design with Tailwind CSS in a React Project ?
Last Updated :
28 Apr, 2025
The integration of Ant Design and Tailwind CSS in a React project presents challenges due to their differing styling conventions. Ant Design offers a feature-rich component library with its own class names, while Tailwind CSS provides a utility-first framework for custom designs. Combining both libraries requires a thoughtful approach to applying their respective styles to the same components, achieving a balance between Ant Design's components and Tailwind CSS's flexible styling capabilities.
Prerequisites:
Steps to Create React Application And Installing Module:
Step 1: Create a React application using the following command:
npx create-react-app foldername
Step 2: After creating your project folder i.e. foldername, move to it using the following command:
cd foldername
Step 3: Installing Ant Design
npm install antd
Step 4: Installing Tailwind CSS
npm install -D tailwindcss
npx tailwindcss init
Step 5: The first command installs Tailwind CSS as a development dependency in your project. The second command generates a default tailwind.config.js file in your project, which you can use to customize your Tailwind CSS styles.
Configuring Tailwind CSS:
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
The content property specifies the files that Tailwind CSS should scan to generate its styles. In this case, it includes all JavaScript and TypeScript files in the src directory.
Now open a file called index.css in your src directory, and add the following code to the file:
@tailwind base;
@tailwind components;
@tailwind utilities;
Project structure:
How to use Antdesign with tailwindcss together in a React ProjectExample 1: Let's see an example code that demonstrates how to use Antdesign with tailwindcss together in a React Project:
JavaScript
import React from "react";
import { Button } from "antd";
import "./App.css";
function App() {
return (
<div className=" flex w-screen
h-screen flex-col justify-center
gap-1 items-center">
<h1 className="text-green-500 font-bold">
GeeksforGeeks
</h1>
<Button className="bg-[#1677ff]"
type="primary">
Primary Button
</Button>
</div>
);
}
export default App;
Step to Run Application: Now start the development server by running the following command:
npm start
Output: App run at http://localhost:3000/
Output
Similar Reads
How to Install Tailwind CSS with Create React App? We will see how to set up Tailwind CSS in a React project using the Create React App. Tailwind CSS is a utility-first CSS framework that allows for rapid development of custom user interfaces. When combined with Create React App, it offers a flexible approach to build modern React applications.Prere
2 min read
How to Create Tailwind CSS Profile Card in React? TailwindCSS can be integrated with React to create highly customizable and responsive profile cards by using utility-first classes for styling. This approach allows you to design visually appealing cards with gradients, rounded corners, and interactive animations, all while ensuring seamless respons
3 min read
How to Add Dark Mode in ReactJS using Tailwind CSS ? Tailwind CSS is a CSS framework that helps in building rapid custom UI. It is a highly customizable, low-level CSS framework that gives you all of the building blocks that you need. Tailwind CSS creates small utilities with a defined set of options enabling easy integration of existing classes direc
3 min read
How to Code Pixel Perfect Design using Tailwind CSS ? Pixel-perfect design refers to the ability to create designs that are accurate down to the pixel level. Tailwind CSS is a popular utility-first CSS framework that can help developers to create pixel-perfect designs quickly and efficiently. In this article, we'll discuss how to code pixel-perfect des
5 min read
How to use Tailwind Forms Plugin with React Select ? Tailwind CSS, a utility-first styling library for web design, offers Tailwind forms as plugins that provide a foundational reset for form styles. This simplifies the styling process for form elements, allowing easy customization with utilities. React Select, a select component library, is employed f
4 min read