The button has base text color text-gray-700 and changes to text-red-600 only on focus.
Step 2: Determine color on focus and blur
When focused, focus:text-red-600 overrides base gray color. When not focused, base gray applies.
Final Answer:
Red when focused, gray when not focused -> Option A
Quick Check:
focus: overrides base style on focus [OK]
Hint: Focus styles override base only when focused [OK]
Common Mistakes:
Thinking focus styles apply always
Confusing base and focus colors
Assuming no color change on focus
4. Identify the error in this Tailwind class usage to add a blue border on focus:
<input class="border focus-border-blue-500" />
medium
A. Border cannot change color on focus
B. Wrong utility name 'border-blue-500'
C. Missing colon after focus
D. Focus variant cannot be used on inputs
Solution
Step 1: Check variant syntax
The focus variant requires a colon after it, like focus:border-blue-500. The code uses focus-border-blue-500 which is invalid.
Step 2: Verify utility and element support
border-blue-500 is a valid utility and inputs support focus styles, so no issues there.
Final Answer:
Missing colon after focus -> Option C
Quick Check:
Variant must have colon separator [OK]
Hint: Always use colon after variant like focus: [OK]
Common Mistakes:
Omitting colon after focus
Using dash instead of colon
Assuming inputs can't have focus styles
5. You want a button to have a green background normally, but change to yellow background only when focused and also have a black border only on focus. Which Tailwind classes should you use?
hard
A. bg-green-500 bg-yellow-400 focus:border-black border
B. bg-green-500 focus:bg-yellow-400 border focus:border-black
C. bg-green-500 focus:bg-yellow-400 border-black focus:border
D. bg-green-500 focus:bg-yellow-400 focus:border-black border
Solution
Step 1: Set base styles
Use bg-green-500 for normal background and border to set border width (default border color).
Step 2: Apply focus variants correctly
Use focus:bg-yellow-400 to change background on focus and focus:border-black to change border color to black only on focus.
Step 3: Verify option correctness
bg-green-500 focus:bg-yellow-400 border focus:border-black correctly uses base green background and border, and changes background and border color on focus. Others misuse border color or width.
Final Answer:
bg-green-500 focus:bg-yellow-400 border focus:border-black -> Option B
Quick Check:
Base border + focus:border-black = black border only on focus [OK]
Hint: Use base classes plus focus: variant for focus styles [OK]
Common Mistakes:
Adding base 'border-black' (always black border)
Missing base 'border' width
Forgetting 'focus:border-black' color
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.