Getting Started
Create React App is deprecated, and instead it is preferrable to use Vite to create a new application from scratch.
Create a project
Use the latest vite package to create a new project using built-in templates using this command - npm create vite@latest
.
Provide a project name, choose a library (react), and TypeScript.
Adding TailwindCSS
TailwindCSS is a library to provide atomic css classes.
To install TailwindCSS use the following commands.
- Install packages
npm install -D tailwindcss postcss autoprefixer
- Setup TailwindCSS config
npx tailwindcss init
- Setup tailwindcss.config.js
/** @type {import('tailwindcss').Config} */
export default {
content: ["./index.html", "./src/**/*.{js,ts,jsx,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
- Setup postcss.config.js
module.exports = {
plugins: [require("tailwindcss"), require("autoprefixer")],
};
- Import TailwindCSS in main css file
@tailwind base;
@tailwind components;
@tailwind utilities;
Start the React server using Vite
Run the following command to start a development server and hot-reload - npm run dev