Bird
Raised Fist0
Tailwindmarkup~20 mins

Transition utilities in Tailwind - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Transition Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
Identify the correct Tailwind class for a smooth opacity transition
Which Tailwind CSS class will create a smooth transition effect when the opacity property changes?
Atransition-opacity
Btransition-all
Ctransition-transform
Dtransition-delay
Attempts:
2 left
💡 Hint
Think about which class targets only opacity changes for transitions.
🧠 Conceptual
intermediate
2:00remaining
Understanding transition duration in Tailwind
What is the effect of applying the class duration-500 in Tailwind CSS?
ASets the transition delay to 500 milliseconds
BSets the transition duration to 50 milliseconds
CSets the transition duration to 500 milliseconds
DSets the transition timing function to ease-in
Attempts:
2 left
💡 Hint
Duration controls how long the transition takes, measured in milliseconds.
rendering
advanced
2:00remaining
Predict the visual effect of combined transition classes
Given the following HTML snippet, what will the user see when hovering over the button?

<button class="bg-blue-500 text-white px-4 py-2 rounded transition-colors duration-300 hover:bg-blue-700">Click me</button>
Tailwind
<button class="bg-blue-500 text-white px-4 py-2 rounded transition-colors duration-300 hover:bg-blue-700">Click me</button>
AThe button background color smoothly changes from blue-500 to blue-700 over 300ms on hover
BThe button text color changes instantly on hover with no transition
CThe button background color changes instantly with no transition on hover
DThe button fades out slowly when hovered
Attempts:
2 left
💡 Hint
Look at which properties the transition applies to and the duration.
selector
advanced
2:00remaining
Which Tailwind class controls the transition timing function?
You want to make a transition that starts slowly and speeds up at the end. Which Tailwind class should you use to set this timing function?
Alinear
Bease-out
Cease-in-out
Dease-in
Attempts:
2 left
💡 Hint
Think about how the speed changes during the transition.
accessibility
expert
3:00remaining
Ensuring accessible transitions with Tailwind
Which approach best ensures that users who prefer reduced motion do not experience distracting animations when using Tailwind CSS transitions?
ARemove all transition classes from elements to avoid animations
BUse the <code>motion-reduce:transition-none</code> class to disable transitions for users with reduced motion preference
CUse <code>transition-all</code> with very short duration to minimize motion
DAdd <code>aria-hidden="true"</code> to elements with transitions
Attempts:
2 left
💡 Hint
Tailwind supports special classes for respecting user motion preferences.

Practice

(1/5)
1. What is the main purpose of Tailwind's transition utilities?
easy
A. To make changes in styles smooth and animated
B. To instantly change styles without animation
C. To add shadows to elements
D. To change the font size of text

Solution

  1. Step 1: Understand transition utilities

    Transition utilities in Tailwind are designed to animate changes in CSS properties smoothly.
  2. Step 2: Identify the purpose

    They help make style changes like color, opacity, or size appear gradual instead of instant.
  3. Final Answer:

    To make changes in styles smooth and animated -> Option A
  4. Quick Check:

    Transition utilities = smooth style changes [OK]
Hint: Transitions smooth style changes visually [OK]
Common Mistakes:
  • Thinking transitions add shadows
  • Believing transitions change font size directly
  • Confusing transitions with instant style changes
2. Which Tailwind class correctly applies a transition on background color with a duration of 500ms?
easy
A. transition-bg duration-500
B. transition-color duration-500
C. transition-background duration-500
D. transition-colors duration-500

Solution

  1. Step 1: Identify the correct transition property class

    Tailwind uses transition-colors to animate color-related properties like background-color.
  2. Step 2: Confirm duration class

    duration-500 sets the animation duration to 500 milliseconds.
  3. Final Answer:

    transition-colors duration-500 -> Option D
  4. Quick Check:

    Use transition-colors for color changes [OK]
Hint: Use transition-colors for color animations [OK]
Common Mistakes:
  • Using non-existent classes like transition-bg
  • Confusing transition-color with transition-colors
  • Forgetting to add duration class
3. What will happen when you hover over this button?
<button class="bg-blue-500 hover:bg-blue-700 transition-colors duration-300">Click me</button>
medium
A. The button text color changes smoothly
B. The background color changes instantly to blue-700
C. The background color smoothly changes to blue-700 over 300ms
D. Nothing changes on hover

Solution

  1. Step 1: Analyze the classes

    The button uses transition-colors and duration-300, so color changes animate over 300 milliseconds.
  2. Step 2: Understand hover effect

    On hover, background changes from bg-blue-500 to bg-blue-700, which will animate smoothly.
  3. Final Answer:

    The background color smoothly changes to blue-700 over 300ms -> Option C
  4. Quick Check:

    transition-colors + duration = smooth color change [OK]
Hint: Hover + transition-colors = smooth background change [OK]
Common Mistakes:
  • Thinking the change is instant
  • Assuming text color changes instead
  • Ignoring the transition classes
4. Identify the error in this Tailwind code snippet:
<div class="transition-opacity duration-200 hover:opacity-50">Fade me</div>
medium
A. Missing transition class to enable transitions
B. No error; the code will fade opacity on hover smoothly
C. Duration class duration-200 is invalid
D. Incorrect use of hover:opacity-50 syntax

Solution

  1. Step 1: Check transition utility usage

    transition-opacity enables smooth opacity changes, which is correct here.
  2. Step 2: Verify hover and duration classes

    hover:opacity-50 correctly sets opacity on hover, and duration-200 sets animation time to 200ms.
  3. Final Answer:

    No error; the code will fade opacity on hover smoothly -> Option B
  4. Quick Check:

    transition-opacity + hover:opacity = smooth fade [OK]
Hint: transition-opacity + hover:opacity works smoothly [OK]
Common Mistakes:
  • Thinking transition class is missing
  • Believing hover syntax is wrong
  • Assuming duration-200 is invalid
5. You want a card to smoothly grow in size and change shadow on hover using Tailwind. Which class combination achieves this best?
hard
A. transition-all duration-500 ease-in-out hover:scale-105 hover:shadow-lg
B. transition-shadow duration-300 hover:scale-110 hover:shadow-xl
C. transition-transform duration-700 hover:scale-110 hover:shadow-md
D. transition-colors duration-400 hover:scale-100 hover:shadow-xl

Solution

  1. Step 1: Identify needed transitions

    We want to animate size (scale) and shadow changes, so transition-all covers all properties.
  2. Step 2: Check duration and easing

    duration-500 with ease-in-out gives a smooth, balanced animation.
  3. Step 3: Confirm hover effects

    hover:scale-105 grows size slightly, hover:shadow-lg adds a bigger shadow on hover.
  4. Final Answer:

    transition-all duration-500 ease-in-out hover:scale-105 hover:shadow-lg -> Option A
  5. Quick Check:

    transition-all + scale + shadow = smooth grow & shadow [OK]
Hint: Use transition-all for multiple property animations [OK]
Common Mistakes:
  • Using transition-shadow misses scale animation
  • Choosing transition-colors ignores size and shadow
  • Picking too short duration for smooth effect