인프런 영문 브랜드 로고
인프런 영문 브랜드 로고

인프런 커뮤니티 질문&답변

윤삼삼님의 프로필 이미지

작성한 질문수

실무에 바로 적용하는 스토리북과 UI 테스트

강의 전 프로젝트 환경설정

[질문 x 공유용] tailwind v4.0 으로 강의랑 다를 때 (import 다름, tailwind.config.js 없어짐 등)

작성

·

227

·

수정됨

3

강의랑 다른 부분 1. tailwind 설치 커맨드

: 커맨드가 간단해졌어요.
npm install tailwindcss @tailwindcss/vite

 

강의랑 다른 부분 2. vite.config.ts
: 이제 ***.tsx, ***.jsx 를 일일히 넣지 않아도 됩니다.

import { defineConfig } from 'vite'
import tailwindcss from '@tailwindcss/vite'
export default defineConfig({
  plugins: [
    tailwindcss(),
  ],
})

 

강의랑 다른 부분 3. @import ~ 3줄
@import "tailwindcss";
한 줄로 초간단해짐..

강의랑 다른 부분 4. tailwind.config.js
: config.js 가 없어졌습니다. (자세한 내용: https://tailwindcss.com/blog/tailwindcss-v4#css-first-configuration)

대신 index.css 에 아래와 같은 형식으로 theme 을 적용할 수 있습니다.

@import 'tailwindcss';

@theme {
  --color-primary: #1d2745;
  --color-secondary: #1de5d4;
  --color-tertiary: #1d2745;
  --color-white: #ffffff;
  --color-mono100: #f1f1f1;
  --color-mono200: #bebebe;
  --color-mono300: #d6d7d9;
  --color-error: #d01e1e;
  --color-social: #395997;
}

답변 2

1

원일님의 프로필 이미지

추가로 tailwind v4 이후부터는 text-xs 과 같은 자체 유틸리티 클래스를 오버라이딩 하려면 index.css 아래와 같이 utility 적용하시면 돼요.

@import 'tailwindcss';

@theme {
  --color-primary: #1d2745;
  ...
}

@layer utilities {
  .text-xs {
    font-size: 12px;
    line-height: 18px;
    letter-spacing: 0px;
    font-weight: 400;
  }

1

강병진님의 프로필 이미지
강병진
지식공유자

감사합니다! 제공해주신 내용은 강의 자료에 추가해두겠습니다. 강의를 수강하시는 다른 분들도 도움 받으실 것 같아요~