Challenge - 5 Problems
Tailwind CSS Mastery in Astro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
How does Tailwind CSS apply styles in Astro components?
Given an Astro component using Tailwind CSS classes, what will be the visual output of the button below?
Astro
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">Click me</button>
Attempts:
2 left
💡 Hint
Look at the Tailwind classes: bg-blue-500 sets background, hover:bg-blue-700 changes it on hover, text-white sets text color, font-bold makes text bold, py-2 and px-4 add padding, rounded adds border radius.
✗ Incorrect
The classes define a blue background that darkens on hover, white bold text, padding for size, and rounded corners for shape.
📝 Syntax
intermediate2:00remaining
Which Tailwind CSS config snippet correctly enables JIT mode in Astro?
Choose the correct Tailwind CSS configuration code to enable Just-In-Time (JIT) mode in an Astro project.
Attempts:
2 left
💡 Hint
JIT mode is enabled by setting mode: 'jit' and specifying content paths in tailwind.config.js.
✗ Incorrect
Option D uses the correct syntax for Tailwind CSS v2 to enable JIT mode and specify content files for purging unused styles.
🔧 Debug
advanced2:00remaining
Why does Tailwind CSS not apply styles in this Astro component?
This Astro component uses Tailwind classes but the styles do not appear in the browser. What is the most likely cause?
Astro
<div class="text-center p-4"> <h1 class="text-3xl font-bold">Welcome</h1> </div>
Attempts:
2 left
💡 Hint
Check if Tailwind CSS is installed and linked correctly in the project setup.
✗ Incorrect
If Tailwind CSS is not imported or configured, the classes will not generate any styles, so the component looks unstyled.
❓ state_output
advanced2:00remaining
What is the rendered output of this Astro component using Tailwind and conditional classes?
Consider this Astro component code snippet. What will be the class attribute of the
Astro
--- const isActive = false; --- <button class={`py-2 px-4 rounded ${isActive ? 'bg-green-500' : 'bg-gray-500'}`}>Submit</button>
Attempts:
2 left
💡 Hint
The template literal adds bg-green-500 if isActive is true, else bg-gray-500.
✗ Incorrect
Since isActive is false, the class string includes bg-gray-500 along with padding and rounded classes.
🧠 Conceptual
expert2:00remaining
How does Tailwind CSS optimize CSS size in Astro projects?
Which mechanism does Tailwind CSS use to keep the final CSS bundle small when integrated with Astro?
Attempts:
2 left
💡 Hint
Think about how Tailwind removes unused styles automatically during build.
✗ Incorrect
Tailwind scans the content files (including Astro components) to detect used classes and removes unused ones, minimizing CSS size.