0
0
Tailwindmarkup~20 mins

Tailwind with React components - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Tailwind React Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2: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>
  );
}
AA plain button with default browser styles
BA red button with white text and square corners
CA blue button with white bold text that darkens on hover and has rounded corners
DA button with blue text on white background and no hover effect
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.
layout
intermediate
2: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?
AclassName="block md:flex-row"
BclassName="grid grid-cols-1 md:grid-cols-2"
CclassName="flex flex-col md:flex-row"
DclassName="flex-row md:flex-col"
Attempts:
2 left
💡 Hint
Think about grid columns that change with screen size.
accessibility
advanced
2:00remaining
Which React button component with Tailwind is most accessible?
Choose the button component that best supports accessibility for screen readers and keyboard users.
A<button className="bg-green-500 text-white p-3 rounded" aria-label="Submit form">Submit</button>
B<button className="bg-green-500 text-white p-3 rounded">Submit</button>
C<div className="bg-green-500 text-white p-3 rounded" role="button" tabIndex="0">Submit</div>
D<button className="bg-green-500 text-white p-3 rounded" disabled>Submit</button>
Attempts:
2 left
💡 Hint
Screen readers benefit from descriptive labels. Keyboard users need focusable elements.
selector
advanced
2: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?
AclassName="active:border-blue-500 border-2 border-gray-300"
BclassName="focus:border-blue-500 border-2 border-gray-300"
CclassName="hover:border-blue-500 border-2 border-gray-300"
DclassName="focus-within:border-blue-500 border-2 border-gray-300"
Attempts:
2 left
💡 Hint
Think about styling a parent when a child element is focused.
🧠 Conceptual
expert
2: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.
AIt provides utility classes that enable fast styling directly in JSX without writing separate CSS files.
BIt allows writing custom CSS files for each component separately.
CIt automatically converts React components into static HTML files.
DIt replaces the need for JavaScript logic inside React components.
Attempts:
2 left
💡 Hint
Think about how Tailwind helps style elements inside JSX.