0
0
Tailwindmarkup~20 mins

Disabled state styling in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Disabled State Styling Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
selector
intermediate
2:00remaining
Identify the correct Tailwind CSS selector for disabled buttons
Which Tailwind CSS class combination correctly applies a gray background and disables pointer events only when a button is disabled?
Tailwind
<button class="btn">Click me</button>
Abtn disabled:bg-gray-400 disabled:pointer-events-none
Bbtn [disabled]:bg-gray-400 [disabled]:pointer-events-none
Cbtn :disabled:bg-gray-400 :disabled:pointer-events-none
Dbtn .disabled:bg-gray-400 .disabled:pointer-events-none
Attempts:
2 left
💡 Hint
Tailwind uses square brackets for attribute selectors in class names.
rendering
intermediate
2:00remaining
What visual effect does this disabled button have?
Given this button code, what will the user see when the button is disabled?
<button disabled class="bg-blue-600 text-white px-4 py-2 rounded [disabled]:bg-gray-400 [disabled]:cursor-not-allowed">Submit</button>
AButton with blue background and cursor changes to not-allowed always
BButton with blue background and cursor changes to pointer on hover
CButton with gray background and cursor changes to not-allowed on hover
DButton with gray background and cursor changes to not-allowed always
Attempts:
2 left
💡 Hint
The cursor style applies only when disabled.
🧠 Conceptual
advanced
2:00remaining
Why use pointer-events-none on disabled elements?
What is the main reason to add pointer-events-none to a disabled button in Tailwind CSS?
ATo prevent the button from receiving mouse events like clicks and hovers
BTo make the button invisible when disabled
CTo change the button text color automatically
DTo enable keyboard navigation on the button
Attempts:
2 left
💡 Hint
Think about how users interact with disabled buttons.
📝 Syntax
advanced
2:00remaining
Which Tailwind class syntax is invalid for disabled styling?
Which option contains an invalid Tailwind CSS class for styling disabled elements?
Adisabled:opacity-50
B[disabled]:bg-gray-300
C[disabled]:cursor-not-allowed
D[disabled]:opacity-50
Attempts:
2 left
💡 Hint
Tailwind uses square brackets for attribute selectors, not just the word 'disabled'.
accessibility
expert
3:00remaining
Best practice for accessible disabled buttons
Which approach best improves accessibility for disabled buttons styled with Tailwind CSS?
AOnly use the disabled attribute and style with <code>[disabled]</code> classes
BRemove the disabled attribute and only use CSS to make the button look disabled
CUse <code>aria-disabled="true"</code> and style with <code>[aria-disabled='true']</code> classes
DUse <code>tabindex="-1"</code> without any disabled attribute or aria attributes
Attempts:
2 left
💡 Hint
Consider screen readers and keyboard users.