- Tạo project react
`npx create-react-app my-app
cd my-app
npm start`
- Cài đặt tailwindcss
`# Using npm
npm install tailwindcss
# Using Yarn
yarn add tailwindcss`
- Tạo tệp cấu hình tailwind
`npx tailwind init --full`
Lúc này sẽ xuất hiện file tailwind.config.js trong thư mục gốc. Tạo file tailwind.css trong thư mục src
- Add tailwind vào file tailwind.css mới tạo
`@tailwind base;
@tailwind components
@tailwind utilities`
- Trong file package.json. Cài đặt để build css từ tailwind. Đoạn scripts trong package.json sẽ có dạng
`code block`
` "scripts": {
"start": "npm run build:css && react-scripts start",
"build": "npm run build:css && react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"build:css": "npx tailwindcss build src/tailwind.css -o src/index.css "
},`
Như vậy là xong, khi chạy npm start, file index.css sẽ chứa tất cả các className mà tailwind cung cấp