본문 바로가기

공부/React

React에서 Tailwindcss 시작하기

공식문서를 읽고 차근차근 따라해보았다.

01. Install Tailwind CSS

npm으로 tailwindcss를 설치한다. 그리고 tailwindcss init을 하면 tailwind.config.js 파일이 생성된다.

npm install -D tailwindcss
npx tailwindcss init

02. Configure your template paths

생성된 tailwind.config.js 파일에서 어떤 파일들이 tailwindcss 적용될 건지 설정한다.

/** @type {import('tailwindcss').Config} */
module.exports = {
  content: [
    "./src/**/*.{js,jsx,ts,tsx}",
  ],
  theme: {
    extend: {},
  },
  plugins: [],
}

03. Add the Tailwind directives to your CSS

index.css 상단에 tailwind 설정한다.

@tailwind base;
@tailwind components;
@tailwind utilities;

04. Start your build process

npm run start 혹은 yarn start로 앱을 다시 실행시키면 된다.

'공부 > React' 카테고리의 다른 글

React Context 사용하기  (0) 2023.02.03
React에서 firebase 사용하기  (0) 2023.02.02
React 에서 .env 파일이란?  (0) 2023.02.01
노마드코더 강의 : React 시작하기 (고전 방법)  (0) 2023.01.27