Conditional styling patterns
📖 Scenario: You are building a simple Next.js app that shows a list of tasks. Each task can be either completed or not. You want to style the tasks differently based on their completion status.
🎯 Goal: Create a Next.js functional component that displays a list of tasks. Use conditional styling to show completed tasks with a green background and incomplete tasks with a red background.
📋 What You'll Learn
Create a list of tasks with exact names and completion status
Add a variable to hold the CSS class names for completed and incomplete tasks
Use conditional styling inside the JSX to apply the correct class based on task completion
Render the list with the correct styles applied
💡 Why This Matters
🌍 Real World
Conditional styling is common in web apps to show different states like completed tasks, errors, or active items clearly to users.
💼 Career
Front-end developers often use conditional styling patterns in React and Next.js to build interactive and accessible user interfaces.
Progress0 / 4 steps