Tailwind CSS
/Intermediate
Tailwind with React
Definition
The specific patterns, pitfalls, and best practices of using Tailwind CSS within a React or JSX environment.
Explain Like I'm New
React uses `className` instead of `class`. But more importantly, React allows you to use template literals to dynamically change classes based on State, which is where developers make the biggest mistakes with Tailwind.
Real World Example
Conditionally hiding a Modal based on an `isOpen` React state.
Common Use Cases
- •React integration
Interactive Example
Loading Code Playground...
Interview Questions
basic
- In React, do you write `class="bg-red-500"` or `className="bg-red-500"`?
intermediate
- Why is it a catastrophic bug to write `className={`bg-${color}-500`}` in React?