Challenge - 5 Problems
Tailwind Color Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate2:00remaining
Correct way to override a color in Tailwind config
You want to override the default
blue color in your Tailwind CSS configuration to a custom hex value #1E40AF. Which option correctly overrides the blue color without removing other default colors?Tailwind
module.exports = {
theme: {
extend: {
colors: {
blue: '#1E40AF',
},
},
},
};Attempts:
2 left
💡 Hint
Use the
extend key inside theme to add or override colors without removing defaults.✗ Incorrect
In Tailwind CSS, to override or add to the default theme colors, you must use
extend inside the theme object. Option A correctly places the new blue color inside extend.colors, preserving other default colors.🧠 Conceptual
intermediate1:30remaining
Effect of overriding colors without extend
What happens if you override the
colors object directly inside theme in Tailwind config without using extend?Attempts:
2 left
💡 Hint
Think about what happens when you replace an object instead of extending it.
✗ Incorrect
When you override the
colors object directly inside theme, Tailwind replaces the entire default colors object with yours. This means only your custom colors are available, and all default colors are lost.❓ selector
advanced1:30remaining
Using custom color in Tailwind CSS class
After overriding the
primary color in your Tailwind config with #FF5733, which class will correctly apply this color as a background?Attempts:
2 left
💡 Hint
Tailwind uses
bg- prefix for background colors and the exact key name for custom colors.✗ Incorrect
When you add a custom color named
primary in Tailwind config, you use bg-primary to apply it as a background color. The -500 suffix is used only for default color scales, not for single custom colors.❓ layout
advanced1:30remaining
Responsive color override with Tailwind
You want the background color to be
primary on small screens and secondary on medium and larger screens. Which class combination achieves this?Attempts:
2 left
💡 Hint
Tailwind uses prefixes like
md: to apply styles at certain screen sizes.✗ Incorrect
The class
bg-primary applies the background color on all screens by default. The md:bg-secondary overrides it on medium and larger screens. This combination sets primary on small and secondary on medium+ screens.❓ accessibility
expert2:30remaining
Ensuring accessible contrast with custom colors
You override Tailwind's color palette with a custom
brand color #123456. What should you do to ensure text using brand background is accessible for users with visual impairments?Attempts:
2 left
💡 Hint
Accessibility means good contrast between text and background colors.
✗ Incorrect
Custom colors may not have enough contrast with default text colors. To ensure accessibility, check the contrast ratio (using tools) and define a text color that meets WCAG guidelines when used on the custom background.