0
0
Tailwindmarkup~20 mins

Overriding color palette in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Tailwind Color Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2: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',
      },
    },
  },
};
Amodule.exports = { theme: { extend: { colors: { blue: '#1E40AF' } } } };
Bmodule.exports = { theme: { colors: { blue: '#1E40AF' } } };
Cmodule.exports = { theme: { extend: { blue: '#1E40AF' } } };
Dmodule.exports = { extend: { colors: { blue: '#1E40AF' } } };
Attempts:
2 left
💡 Hint
Use the extend key inside theme to add or override colors without removing defaults.
🧠 Conceptual
intermediate
1:30remaining
Effect of overriding colors without extend
What happens if you override the colors object directly inside theme in Tailwind config without using extend?
AThe colors are ignored and default colors remain unchanged.
BYour custom colors are merged with default colors automatically.
CAll default colors are replaced, only your custom colors remain.
DTailwind throws a configuration error and fails to build.
Attempts:
2 left
💡 Hint
Think about what happens when you replace an object instead of extending it.
selector
advanced
1: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?
Abg-primary
Bbackground-primary
Cbg-primary-500
Dbackground-primary-500
Attempts:
2 left
💡 Hint
Tailwind uses bg- prefix for background colors and the exact key name for custom colors.
layout
advanced
1: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?
Abg-secondary md:bg-primary
Bbg-primary md:bg-secondary
Cmd:bg-primary bg-secondary
Dbg-primary bg-secondary md:bg-primary
Attempts:
2 left
💡 Hint
Tailwind uses prefixes like md: to apply styles at certain screen sizes.
accessibility
expert
2: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?
AAdd <code>aria-hidden="true"</code> to elements with <code>brand</code> background.
BUse the <code>brand</code> color for both background and text for consistency.
COnly rely on default Tailwind colors for text to ensure accessibility.
DCheck contrast ratio and add a custom text color that meets WCAG standards.
Attempts:
2 left
💡 Hint
Accessibility means good contrast between text and background colors.