0
0
Tailwindmarkup~20 mins

Media-based dark mode strategy in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Dark Mode Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
How does Tailwind detect dark mode using media queries?
Tailwind CSS can switch styles based on the user's system preference for dark mode. Which media query does Tailwind use internally to detect this preference?
A@media (prefers-color-scheme: dark)
B@media (color-scheme: dark)
C@media (dark-mode: enabled)
D@media (theme: dark)
Attempts:
2 left
💡 Hint
Think about how browsers expose user color scheme preferences.
📝 Syntax
intermediate
2:00remaining
Which Tailwind config enables media-based dark mode?
You want Tailwind to apply dark mode styles based on the user's system preference. Which configuration in tailwind.config.js correctly enables this?
Tailwind
module.exports = {
  darkMode: '???',
  // other config
}
Atrue
B'media'
C'class'
D'system'
Attempts:
2 left
💡 Hint
The option name is a simple string matching the detection method.
rendering
advanced
2:00remaining
What background color will this element have in dark mode?
Given this Tailwind HTML snippet with media-based dark mode enabled, what background color will the div have when the user prefers dark mode?
Tailwind
<div class="bg-white dark:bg-gray-800 p-4">
  Hello World
</div>
ATransparent background
BBlack background
CGray-800 background
DWhite background
Attempts:
2 left
💡 Hint
The 'dark:' prefix applies styles only in dark mode.
selector
advanced
2:00remaining
Which CSS selector does Tailwind generate for dark mode with media strategy?
When Tailwind is configured with darkMode: 'media', what CSS selector does it generate for dark mode styles?
A.dark .bg-gray-800 { background-color: #1f2937; }
B@media (dark-mode: enabled) { .bg-gray-800 { background-color: #1f2937; } }
C:root.dark { background-color: #1f2937; }
D@media (prefers-color-scheme: dark) { .dark\:bg-gray-800 { background-color: #1f2937; } }
Attempts:
2 left
💡 Hint
Tailwind wraps dark styles inside a media query for media strategy.
accessibility
expert
2:00remaining
Why is media-based dark mode strategy better for accessibility?
Choose the best reason why using media-based dark mode strategy improves accessibility for users.
AIt respects the user's system preference automatically without extra toggles.
BIt forces all websites to use dark mode regardless of user preference.
CIt disables all light mode styles to reduce confusion.
DIt requires users to manually add a dark mode toggle button.
Attempts:
2 left
💡 Hint
Think about how users set their preferences on their devices.