Tailwind CSS Academy · 강의

전환 유틸리티

transition-*으로 CSS 전환을 활성화하고 transition-colors, transition-transform, transition-all로 애니메이션을 적용할 속성을 선택합니다.

레슨 1/413개 단계

전환 유틸리티은(는) CoddyKit의 무료 Tailwind CSS Academy 강의입니다. 이것은 4개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Tailwind CSS Academy 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Tailwind CSS Academy 강의에는 총 4개의 강의가 포함되어 있습니다.

이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.

Why CSS Transitions Matter

CSS transitions make state changes smooth and feel intentional rather than abrupt. When a button changes background color on hover, a sidebar slides in, or an input gets a focus ring, transitions communicate to users that something happened and guide their attention. Tailwind's transition utilities let you add these animations with a single class — no custom CSS required for the most common use cases.

The transition Utility

The base transition utility enables CSS transitions for the most commonly animated properties: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, and filter. Adding just transition to a button is usually enough to make hover color changes animate smoothly.

<!-- Simple hover transition on a button -->
<button class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg transition">
  Hover Me
</button>

<!-- The transition class enables smooth color changes -->
<!-- Without it, the color snaps instantly on hover -->
<!-- With it, the background color animates over 150ms (Tailwind default) -->

Specific Transition Properties

Use targeted transition utilities to animate only specific properties. This is more performant than transition-all because the browser does not need to recalculate all possible animated properties on every frame. Tailwind provides transition-colors, transition-opacity, transition-shadow, transition-transform, and transition-all for different needs.

<!-- Only animate colors -->
<button class="bg-blue-600 hover:bg-blue-700 text-white transition-colors">
  Color Transition
</button>

<!-- Only animate transform (GPU accelerated) -->
<div class="hover:scale-105 transition-transform cursor-pointer">
  Scale on hover
</div>

<!-- Only animate opacity -->
<div class="opacity-100 hover:opacity-75 transition-opacity">
  Fade on hover
</div>

<!-- Animate shadow (depth change) -->
<div class="shadow hover:shadow-lg transition-shadow rounded-xl p-4">
  Shadow depth change
</div>

transition-all vs Specific Properties

transition-all transitions every animatable CSS property simultaneously. While convenient, it can cause unexpected behavior — for example, layout properties like height or width becoming animated when you only wanted color changes. It is also less performant because the browser tracks all properties. Use specific transition utilities whenever possible; reach for transition-all only when you genuinely need multiple unrelated properties to animate together.

<!-- transition-all: animates EVERYTHING that changes -->
<div class="bg-gray-100 hover:bg-blue-50 hover:scale-102 transition-all">
  All properties animate (colors, transforms, borders...)
</div>

<!-- More precise: only animate what you intend -->
<div class="bg-gray-100 hover:bg-blue-50 hover:scale-102 transition-colors transition-transform">
  Only colors and transforms animate
</div>

Combining Transition with State Variants

Transition utilities work by enabling the CSS transition property. State variants like hover:, focus:, and group-hover: provide the before and after states that the transition animates between. Always place the transition class on the base element (not inside the variant) so it applies in both directions — the transition runs on enter AND exit of the state.

<!-- Transition enables smooth enter AND exit -->
<a class="text-gray-600 hover:text-blue-600 transition-colors duration-200"
   href="#">
  Animated link — hover to see color change both ways
</a>

<!-- Card with multiple transitions -->
<div class="bg-white hover:bg-blue-50
            shadow-sm hover:shadow-md
            border border-gray-200 hover:border-blue-200
            transition-all duration-200 rounded-xl p-6 cursor-pointer">
  Interactive card
</div>

Animating Opacity and Visibility

Fading elements in and out requires transitioning opacity combined with managing visibility or display. CSS transitions cannot animate to or from display: none, so use opacity plus pointer-events-none for simple fade effects. For elements that must truly disappear (removing them from the tab order), combine opacity transitions with JavaScript class toggling.

<!-- Fade an element using opacity + pointer-events -->
<div id="tooltip"
     class="opacity-0 pointer-events-none
            group-hover:opacity-100 group-hover:pointer-events-auto
            transition-opacity duration-200
            bg-gray-900 text-white text-xs px-2 py-1 rounded">
  Tooltip content
</div>

<!-- JavaScript fade with class toggle -->
<!-- Remove: classList.add('opacity-0', 'pointer-events-none') -->
<!-- Show: classList.remove('opacity-0', 'pointer-events-none') -->

Transform Transitions

Transform transitions are particularly smooth because they run on the GPU rather than triggering layout recalculations. Tailwind's scale-*, rotate-*, translate-*, and skew-* utilities all animate cleanly with transition-transform. Scale effects on cards and buttons, rotation effects on icons, and slide-in effects on panels all use this approach for best performance.

<!-- Subtle scale effect on card hover -->
<div class="hover:scale-105 transition-transform duration-200 cursor-pointer bg-white rounded-xl p-6 shadow">
  Card that scales up on hover
</div>

<!-- Rotating icon -->
<button class="group p-2">
  <svg class="w-5 h-5 group-hover:rotate-180 transition-transform duration-300">
    <!-- chevron icon -->
  </svg>
</button>

<!-- Slide from left with translateX -->
<div class="-translate-x-full open:translate-x-0 transition-transform duration-300">
  Sidebar panel
</div>

Reduced Motion Accessibility

Some users experience motion sickness or seizures from animations and set their OS to Reduce Motion. Tailwind provides the motion-reduce: and motion-safe: variants that activate based on the user's prefers-reduced-motion media query. Use motion-safe: to apply animations only when the user has not requested reduced motion, making your transitions accessible by default.

<!-- Only animate when user is OK with motion -->
<button class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg
               motion-safe:transition-colors motion-safe:duration-200">
  Accessible Button
</button>

<!-- Remove transitions entirely for reduced-motion users -->
<div class="hover:scale-105 motion-reduce:transform-none
            motion-safe:transition-transform motion-safe:duration-200">
  Accessible card hover
</div>

Transition on Focus States

Focus transitions are particularly important for keyboard navigation. When a user tabs to an input or button, the focus ring should appear smoothly rather than snapping. Apply transition to all interactive elements so the focus ring transition feels as polished as the hover transition. Include focus:ring-* and focus:ring-offset-* with a transition for the best keyboard experience.

<input
  type="text"
  class="
    w-full px-4 py-2 rounded-lg
    border border-gray-300
    text-gray-900 placeholder:text-gray-400
    ring-0
    focus:ring-2 focus:ring-blue-500 focus:border-transparent focus:outline-none
    transition duration-150
  "
  placeholder="Smooth focus ring transition"
/>

Multiple Transition Properties

You can combine multiple specific transition utilities on a single element to animate only a precise set of properties. Tailwind composes these using the CSS transition-property shorthand. Stacking transition-colors and transition-shadow on the same element makes both colors and shadows animate while leaving other properties (like transforms) instant.

<!-- Animate colors AND shadows, but not transforms -->
<div class="
  bg-white hover:bg-gray-50
  shadow hover:shadow-md
  scale-100 hover:scale-105
  transition-colors transition-shadow
  duration-200 rounded-xl p-6
">
  Colors and shadows animate smoothly;
  scale change happens instantly (no transition-transform)
</div>

Transition in Practice: Complete Example

Here is a real-world navigation link with all transitions polished: the background fades in on hover, the text color changes simultaneously, the underline grows from left to right using a scale transform, and focus states match the hover style exactly. Every interaction feels intentional and smooth without a single line of custom CSS.

<a
  href="/features"
  class="
    relative inline-block
    text-gray-600 hover:text-blue-600
    font-medium text-sm
    pb-0.5
    transition-colors duration-150
    focus:outline-none focus:text-blue-600
    group
  "
>
  Features
  <!-- Animated underline -->
  <span class="
    absolute bottom-0 left-0 w-full h-0.5 bg-blue-600
    scale-x-0 group-hover:scale-x-100
    transition-transform duration-200 origin-left
  "></span>
</a>

Quick Check

Test your understanding of Tailwind's transition utilities.

Lesson Recap

In this lesson you learned: the base transition utility enables smooth animation for common properties, specific transition utilities like transition-colors and transition-transform are more performant than transition-all, and the motion-safe: variant ensures animations only apply when the user has not requested reduced motion. Next up we control transition duration and timing functions.

무료로 시작

AI 튜터와 함께 HTML을(를) 배우세요 — 무료

브라우저에서 실제 코드를 작성하고 실행하며, 24/7 AI 튜터로부터 즉각적인 도움을 받고, 웹이나 앱에서 중단한 부분부터 계속 학습하세요.

코스
30
레슨
120

자주 묻는 질문

“전환 유틸리티” 강의는 무료인가요?

네 — “전환 유틸리티” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Tailwind CSS Academy 강의 전체를 잠금 해제할 수 있습니다. Tailwind CSS Academy 강의에는 총 4개의 강의가 포함되어 있습니다.

“전환 유틸리티”에서 뭘 배우나요?

transition-*으로 CSS 전환을 활성화하고 transition-colors, transition-transform, transition-all로 애니메이션을 적용할 속성을 선택합니다. 브라우저에서 직접 실행하는 실습 코드로 Tailwind CSS Academy을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.

Tailwind CSS Academy을(를) 시작하는 데 경험이 필요한가요?

사전 경험은 필요하지 않습니다. CoddyKit의 Tailwind CSS Academy은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 4개 중 1번째 강의입니다.

“전환 유틸리티” 강의는 얼마나 걸리나요?

대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.

이 Tailwind CSS Academy 강의에서 코드를 작성하고 실행할 수 있나요?

네. 모든 Tailwind CSS Academy 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.

이 강의의 모든 강의

  1. 전환 유틸리티
  2. 지속 시간과 이징
  3. 내장 키프레임 애니메이션
  4. 구성 파일의 사용자 지정 애니메이션
← Tailwind CSS Academy(으)로 돌아가기