Challenge - 5 Problems
Tailwind React Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate2:00remaining
What is the rendered output of this React component using Tailwind?
Consider this React component using Tailwind CSS classes. What will you see in the browser?
Tailwind
import React from 'react'; export default function Button() { return ( <button className="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 color, 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 rounded corners.
✗ Incorrect
The button uses Tailwind classes to style background color, text color, font weight, padding, and rounded corners. The hover:bg-blue-700 changes the background color when hovered. So visually, it is a blue button with white bold text that darkens on hover and has rounded corners.
❓ layout
intermediate2:00remaining
Which Tailwind class combination creates a responsive two-column layout in React?
You want to create a layout with two columns side by side on medium screens and above, but stacked on small screens. Which Tailwind classes achieve this?
Attempts:
2 left
💡 Hint
Think about grid columns that change with screen size.
✗ Incorrect
Using grid with grid-cols-1 makes one column on small screens. md:grid-cols-2 changes to two columns on medium screens and larger. This creates a responsive two-column layout.
❓ accessibility
advanced2:00remaining
Which React button component with Tailwind is most accessible?
Choose the button component that best supports accessibility for screen readers and keyboard users.
Attempts:
2 left
💡 Hint
Screen readers benefit from descriptive labels. Keyboard users need focusable elements.
✗ Incorrect
Option A uses a native button element with an aria-label describing the action. This helps screen readers understand the button's purpose. Option A uses a div with role and tabindex but is less semantic. Option A disables the button, preventing interaction. Option A lacks an aria-label which might be needed if the button text is unclear.
❓ selector
advanced2:00remaining
Which Tailwind selector applies styles only when a child input is focused inside a div?
You want to style a div's border color only when the input inside it is focused. Which Tailwind class achieves this?
Attempts:
2 left
💡 Hint
Think about styling a parent when a child element is focused.
✗ Incorrect
The focus-within variant applies styles to the parent element when any child element has focus. So the div's border changes color when the input inside is focused.
🧠 Conceptual
expert2:00remaining
What is the main benefit of using Tailwind CSS with React components?
Choose the best explanation for why developers use Tailwind CSS inside React components.
Attempts:
2 left
💡 Hint
Think about how Tailwind helps style elements inside JSX.
✗ Incorrect
Tailwind offers utility classes that you add directly to JSX elements to style them quickly. This avoids writing separate CSS files and speeds up development.