What does it mean to extend default theme values in Tailwind CSS?
Extending default theme values means adding new styles or values to Tailwind's built-in design system without removing or replacing the original ones. It helps keep the default styles while customizing your project.
Click to reveal answer
beginner
How do you extend colors in Tailwind's theme configuration?
You add new colors inside the extend section of the theme in tailwind.config.js. For example:
Why should you use extend instead of replacing the whole theme section?
Using extend keeps all the default Tailwind styles intact and only adds your custom values. Replacing the whole theme section removes all defaults, which can break your design or require redefining everything.
Click to reveal answer
beginner
What is the file name where you extend Tailwind's default theme values?
The file is tailwind.config.js. This is where you configure and extend Tailwind's default theme settings for your project.
Click to reveal answer
intermediate
Give an example of extending font sizes in Tailwind CSS.
Step 1: Understand Tailwind class naming for custom colors
Tailwind generates utility classes using the exact key name from the theme object as the class suffix, preserving case and format. softGreen (camelCase) becomes bg-softGreen.
Step 2: Form the background color class
Background color classes are bg- followed by the exact color key name.
Final Answer:
bg-softGreen -> Option D
Quick Check:
Exact key match: softGreen -> bg-softGreen [OK]
Hint: Theme keys match class suffixes exactly, case preserved [OK]
Common Mistakes:
Assuming Tailwind converts camelCase to lowercase
Adding hyphens between camelCase words
Using underscores in place of camelCase
4. Identify the error in this Tailwind config snippet that tries to add a new spacing value:
{
theme: {
extend: {
spacing: 72: '18rem'
}
}
}
medium
A. Spacing key should be inside colors
B. Missing curly braces around spacing values
C. Colon used instead of comma between key and value
D. extend should be outside theme
Solution
Step 1: Check syntax for spacing extension
The spacing key must have an object with key-value pairs inside curly braces.
Missing curly braces around spacing values -> Option B
Quick Check:
Objects need braces: spacing: { 72: '18rem' } [OK]
Hint: Use braces {} for objects inside extend keys [OK]
Common Mistakes:
Forgetting braces around nested objects
Putting spacing inside colors by mistake
Placing extend outside theme
5. You want to add a new font size called xxl with value 2.5rem but keep all default font sizes. Which config snippet correctly extends the fontSize theme without losing defaults?