Step 1: Remove Bootstrap
Uninstall Bootstrap:
Remove the Bootstrap package from your project using npm or yarn:
terminal
npm uninstall bootstrap
or
terminal
yarn remove bootstrap
Remove Bootstrap Imports:
Remove any Bootstrap-related imports from your React components and global stylesheets.
For example, if you had this in your index.js or App.js:
import 'bootstrap/dist/css/bootstrap.min.css';
Remove it.
Remove Bootstrap Classes:
Go through your components and remove all Bootstrap-specific classes (e.g., btn, container, row, col).
Step 2: Install Tailwind CSS
Install Tailwind CSS:
Install Tailwind CSS and its dependencies using npm or yarn:
terminal
npm install -D tailwindcss postcss autoprefixer
or
terminal
yarn add -D tailwindcss postcss autoprefixer
Initialize Tailwind CSS:
Generate the tailwind.config.js and postcss.config.js files:
terminal
npx tailwindcss init -p
Configure Tailwind CSS:
Open the tailwind.config.js file and configure the content property to include your React components:
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}", // Add paths to all your React components
],
theme: {
extend: {},
},
plugins: [],
};
Add Tailwind to Your CSS:
Create a src/index.css file (if it doesn’t already exist) and add the following Tailwind directives:
@tailwind base;
@tailwind components;
@tailwind utilities;
Import Tailwind CSS:
Import the index.css file in your src/index.js or src/App.js:
import './index.css';
Step 3: Replace Bootstrap Classes with Tailwind Classes
Now that Tailwind CSS is set up, you can start replacing Bootstrap classes with Tailwind utility classes.
Example:
-> Layout
Bootstrap Class | Tailwind Class
container | container mx-auto
row flex | flex-wrap -mx-4
col px-4 | (with flex or grid)