- 建立專案
npx create-react-app [project-name] --template typescript
cd [project-name]
- 安裝 TailwindCSS 及其相依套件:
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p
- 設定 tailwind.config.js:
/** @type {import('tailwindcss').Config} */
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}
- 在 src/index.css 中加入 Tailwind directives:
@tailwind base;
@tailwind components;
@tailwind utilities;