Recall & Review
beginner
What does the media-based dark mode strategy use to switch themes?
It uses the user's system preference detected by the
prefers-color-scheme media query to automatically switch between light and dark themes.Click to reveal answer
beginner
How do you enable dark mode in Tailwind CSS using media queries?
Set
darkMode: 'media' in the Tailwind config file. This tells Tailwind to apply dark styles when the user's system prefers dark mode.Click to reveal answer
beginner
Which CSS media feature detects if a user prefers dark mode?
The media feature is
prefers-color-scheme: dark. It matches when the user’s system is set to dark mode.Click to reveal answer
beginner
How do you write a Tailwind class that applies only in dark mode with media strategy?Prefix the class with <code>dark:</code>. For example, <code>dark:bg-gray-900</code> sets a dark background only when dark mode is active.Click to reveal answer
beginner
Why is media-based dark mode strategy user-friendly?
Because it respects the user's system preference automatically, so the website matches their chosen theme without extra settings.
Click to reveal answer
Which Tailwind config option enables media-based dark mode?
✗ Incorrect
Setting
darkMode: 'media' tells Tailwind to use the system's dark mode preference.What CSS media query detects dark mode preference?
✗ Incorrect
The correct media query is
prefers-color-scheme: dark.How do you apply a background color only in dark mode using Tailwind?
✗ Incorrect
Use the
dark: prefix to apply styles only in dark mode.What happens if a user’s system is set to light mode with media-based dark mode?
✗ Incorrect
The site uses light styles because the system preference is light.
Which is a benefit of media-based dark mode strategy?
✗ Incorrect
It automatically matches the user’s system theme without extra input.
Explain how media-based dark mode strategy works in Tailwind CSS.
Think about how the website knows when to show dark styles.
You got /4 concepts.
Describe the advantages of using media-based dark mode strategy for users.
Consider what users want from theme switching.
You got /4 concepts.