Bird
Raised Fist0
Tailwindmarkup~20 mins

Overriding color palette in Tailwind - Practice Problems & Coding Challenges

Choose your learning style10 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.

Practice

(1/5)
1. What is the main purpose of overriding the color palette in Tailwind CSS?
easy
A. To add or change colors to match your brand or design needs
B. To remove all default colors from Tailwind
C. To disable Tailwind's color utilities completely
D. To change the font sizes in Tailwind

Solution

  1. Step 1: Understand Tailwind's default colors

    Tailwind provides a default color palette for quick styling.
  2. Step 2: Purpose of overriding colors

    Overriding lets you add or change colors to fit your brand or design.
  3. Final Answer:

    To add or change colors to match your brand or design needs -> Option A
  4. Quick Check:

    Overriding colors = Customize palette [OK]
Hint: Overriding colors means customizing palette, not removing defaults [OK]
Common Mistakes:
  • Thinking overriding removes all default colors
  • Confusing color palette with font sizes
  • Believing overriding disables Tailwind features
2. Which is the correct way to add a custom color named brandBlue without removing default colors in tailwind.config.js?
easy
A. extend: { colors: { brandBlue: '#1DA1F2' } }
B. colors: { brandBlue: '#1DA1F2' }
C. theme: { colors: { brandBlue: '#1DA1F2' } }
D. colors: extend { brandBlue: '#1DA1F2' }

Solution

  1. Step 1: Use extend inside theme

    To add colors without removing defaults, use extend inside theme.
  2. Step 2: Correct syntax for adding colors

    The correct syntax is extend: { colors: { brandBlue: '#1DA1F2' } }.
  3. Final Answer:

    extend: { colors: { brandBlue: '#1DA1F2' } } -> Option A
  4. Quick Check:

    Use extend to add colors [OK]
Hint: Always put new colors inside extend.colors to keep defaults [OK]
Common Mistakes:
  • Adding colors directly under colors removes defaults
  • Wrong object nesting in config
  • Syntax errors like missing braces
3. Given this tailwind.config.js snippet, what background color will bg-brandBlue apply?
module.exports = {
  theme: {
    extend: {
      colors: {
        brandBlue: '#1DA1F2'
      }
    }
  }
}
medium
A. A light gray color
B. The default Tailwind blue color
C. A bright blue color #1DA1F2
D. No color, it will cause an error

Solution

  1. Step 1: Check the custom color definition

    The config adds brandBlue with hex #1DA1F2.
  2. Step 2: Understand class usage

    The class bg-brandBlue uses this custom color as background.
  3. Final Answer:

    A bright blue color #1DA1F2 -> Option C
  4. Quick Check:

    bg-brandBlue = #1DA1F2 [OK]
Hint: Custom colors apply exactly as defined in config [OK]
Common Mistakes:
  • Assuming default blue is used instead
  • Thinking it causes an error without import
  • Confusing color names with default palette
4. What is wrong with this Tailwind config snippet if you want to add a custom color but keep defaults?
module.exports = {
  theme: {
    colors: {
      brandRed: '#E02424'
    }
  }
}
medium
A. Custom colors must be outside the theme object
B. The color hex code is invalid
C. The config syntax is missing a comma
D. It removes all default colors because it overwrites colors directly

Solution

  1. Step 1: Check how colors are added

    Adding colors directly under colors replaces all default colors.
  2. Step 2: Correct way to keep defaults

    Use extend: { colors: { brandRed: '#E02424' } } inside theme to add without removing.
  3. Final Answer:

    It removes all default colors because it overwrites colors directly -> Option D
  4. Quick Check:

    Direct colors overwrite defaults [OK]
Hint: Direct colors overwrite defaults; use extend to add [OK]
Common Mistakes:
  • Not using extend and losing default colors
  • Thinking hex code is wrong
  • Misplacing config keys
5. You want to override the Tailwind color palette to add brandGreen and also change the default blue color to #005f73. Which config snippet correctly does this?
hard
A. theme: { extend: { colors: { brandGreen: '#0a9396' } }, blue: '#005f73' }
B. theme: { extend: { colors: { brandGreen: '#0a9396', blue: '#005f73' } } }
C. theme: { extend: { colors: { brandGreen: '#0a9396' } }, colors: { blue: '#005f73' } }
D. theme: { colors: { brandGreen: '#0a9396', blue: '#005f73' } }

Solution

  1. Step 1: Adding new colors

    Use theme.extend.colors to add brandGreen without removing defaults.
  2. Step 2: Overriding existing colors

    To change default blue, use extend.colors.blue: '#005f73'; this overrides it while keeping other defaults.
  3. Step 3: Correct config

    Place both in extend.colors: { brandGreen: '#0a9396', blue: '#005f73' }.
  4. Final Answer:

    theme: { extend: { colors: { brandGreen: '#0a9396', blue: '#005f73' } } } -> Option B
  5. Quick Check:

    New + override = extend.colors [OK]
Hint: Use extend.colors for adding new colors and overriding existing ones [OK]
Common Mistakes:
  • Defining overrides under theme.colors (loses default palette)
  • Overwriting colors without extend losing defaults
  • Incorrect nesting of colors object
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard