0
0
Tailwindmarkup~10 mins

Peer modifier (sibling state reaction) in Tailwind - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to change the text color of the sibling <p> when the checkbox is checked.

Tailwind
<input type="checkbox" id="toggle" class="peer" />
<p class="[1]">This text changes color when checkbox is checked.</p>
Drag options to blanks, or click blank then click option'
Ahover:text-blue-500
Bchecked:text-blue-500
Cfocus:text-blue-500
Dpeer-checked:text-blue-500
Attempts:
3 left
💡 Hint
Common Mistakes
Using checked: instead of peer-checked:
Forgetting to add the peer class to the checkbox
2fill in blank
medium

Complete the code to make the sibling <div> visible only when the checkbox is checked.

Tailwind
<input type="checkbox" id="show" class="peer" />
<div class="hidden [1]">Visible when checked</div>
Drag options to blanks, or click blank then click option'
Apeer-hover:block
Bchecked:block
Cpeer-checked:block
Dfocus:block
Attempts:
3 left
💡 Hint
Common Mistakes
Using checked:block which does not affect siblings
Not setting the initial state to hidden
3fill in blank
hard

Fix the error in the code to change the sibling <span> text to red when the checkbox is checked.

Tailwind
<input type="checkbox" id="check" class="peer" />
<span class="[1]">Change my color</span>
Drag options to blanks, or click blank then click option'
Apeer-checked:text-red-600
Bfocus:text-red-600
Chover:text-red-600
Dchecked:text-red-600
Attempts:
3 left
💡 Hint
Common Mistakes
Using checked: which does not affect siblings
Using hover: or focus: which are unrelated here
4fill in blank
hard

Fill both blanks to make the sibling <div> background green and text white when the checkbox is checked.

Tailwind
<input type="checkbox" id="bg-toggle" class="peer" />
<div class="[1] [2]">Styled on check</div>
Drag options to blanks, or click blank then click option'
Apeer-checked:bg-green-500
Bbg-gray-200
Cpeer-checked:text-white
Dtext-black
Attempts:
3 left
💡 Hint
Common Mistakes
Using checked: instead of peer-checked:
Forgetting to style both background and text color
5fill in blank
hard

Fill all three blanks to make the sibling <button> scale up, change background, and show shadow when the checkbox is checked.

Tailwind
<input type="checkbox" id="scale-toggle" class="peer" />
<button class="transform transition [1] [2] [3]">Hover me</button>
Drag options to blanks, or click blank then click option'
Apeer-checked:scale-110
Bpeer-checked:bg-purple-600
Cpeer-checked:shadow-lg
Dhover:scale-110
Attempts:
3 left
💡 Hint
Common Mistakes
Using hover: instead of peer-checked:
Missing transform class which is needed for scaling