Bird
Raised Fist0
Tailwindmarkup~10 mins

Preset sharing across projects in Tailwind - Interactive Code Practice

Choose your learning style10 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import a Tailwind preset in your tailwind.config.js file.

Tailwind
module.exports = {
  presets: [require([1])],
  theme: {
    extend: {},
  },
  plugins: [],
}
Drag options to blanks, or click blank then click option'
A'./tailwind.css'
B'tailwindcss/defaultTheme'
C'./styles.css'
D'./my-preset.js'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a CSS file path instead of a JS preset file.
Forgetting to wrap the path in quotes.
Not using require() to import the preset.
2fill in blank
medium

Complete the code to export a Tailwind preset configuration in my-preset.js.

Tailwind
module.exports = {
  theme: {
    extend: {
      colors: [1],
    },
  },
};
Drag options to blanks, or click blank then click option'
A'primary: #1da1f2, secondary: #14171a'
B['primary', '#1da1f2']
C{ primary: '#1da1f2', secondary: '#14171a' }
D['#1da1f2', '#14171a']
Attempts:
3 left
💡 Hint
Common Mistakes
Using arrays instead of objects for colors.
Writing colors as a string instead of an object.
Missing curly braces around the color definitions.
3fill in blank
hard

Fix the error in the preset export by completing the missing keyword.

Tailwind
[1] tailwindPreset = {
  theme: {
    extend: {
      spacing: {
        '72': '18rem',
      },
    },
  },
};

module.exports = tailwindPreset;
Drag options to blanks, or click blank then click option'
Afunction
Bconst
Cvar
Dlet
Attempts:
3 left
💡 Hint
Common Mistakes
Using function instead of a variable declaration.
Using var or let when const is preferred.
4fill in blank
hard

Fill both blanks to extend the Tailwind theme with custom font family and font size.

Tailwind
module.exports = {
  presets: [require('./my-preset.js')],
  theme: {
    extend: {
      fontFamily: [1],
      fontSize: [2],
    },
  },
  plugins: [],
};
Drag options to blanks, or click blank then click option'
A{ sans: ['Helvetica', 'Arial', 'sans-serif'] }
B{ base: '16px', lg: '20px' }
C{ base: '1rem', lg: '1.25rem' }
D['Helvetica', 'Arial']
Attempts:
3 left
💡 Hint
Common Mistakes
Using arrays directly for fontFamily instead of inside an object.
Using pixel units for fontSize instead of rem units.
Mixing up fontFamily and fontSize formats.
5fill in blank
hard

Fill all three blanks to create a preset that adds a custom color, spacing, and a plugin.

Tailwind
const myPreset = {
  theme: {
    extend: {
      colors: [1],
      spacing: [2],
    },
  },
  plugins: [[3]],
};

module.exports = myPreset;
Drag options to blanks, or click blank then click option'
A{ brandBlue: '#0d6efd' }
B{ '128': '32rem' }
Crequire('@tailwindcss/forms')
D['@tailwindcss/typography']
Attempts:
3 left
💡 Hint
Common Mistakes
Using arrays instead of objects for colors or spacing.
Adding plugin names as strings instead of using require().
Forgetting to export the preset object.

Practice

(1/5)
1. What is the main purpose of using presets in Tailwind CSS configuration?
easy
A. To create custom CSS animations
B. To share common Tailwind settings across multiple projects
C. To add new color palettes only for one project
D. To compile Tailwind CSS faster on a single project

Solution

  1. Step 1: Understand the role of presets

    Presets are used to share configuration settings like colors, fonts, and plugins across projects.
  2. Step 2: Compare options

    Options B, C, and D describe features unrelated to sharing configs across projects.
  3. Final Answer:

    To share common Tailwind settings across multiple projects -> Option B
  4. Quick Check:

    Presets = Shared config across projects [OK]
Hint: Presets = shared config for multiple projects [OK]
Common Mistakes:
  • Thinking presets only add colors or animations
  • Confusing presets with plugins
  • Believing presets speed up compilation
2. Which of the following is the correct way to include a preset in tailwind.config.js?
easy
A. presets: require('tailwind-preset')
B. presets: ['tailwind-preset']
C. presets: [require('tailwind-preset')]
D. preset: [require('tailwind-preset')]

Solution

  1. Step 1: Check the correct property name and syntax

    The property is presets (plural) and it expects an array of required modules.
  2. Step 2: Validate each option

    presets: [require('tailwind-preset')] uses presets with an array containing require('tailwind-preset'), which is correct syntax.
  3. Final Answer:

    presets: [require('tailwind-preset')] -> Option C
  4. Quick Check:

    Presets property + array + require() = correct [OK]
Hint: Use presets as an array with require() inside [OK]
Common Mistakes:
  • Using singular 'preset' instead of 'presets'
  • Not wrapping require() inside an array
  • Passing string instead of require()
3. Given this tailwind.config.js snippet, what will be the background color of a div with class bg-primary?
module.exports = {
  presets: [require('./shared-preset')],
  theme: {
    extend: {
      colors: {
        primary: '#ff0000'
      }
    }
  }
}
And the shared-preset.js contains:
module.exports = {
  theme: {
    colors: {
      primary: '#00ff00'
    }
  }
}
medium
A. #ff0000 (red) from local config
B. No color applied, class invalid
C. #00ff00 (green) from preset
D. Error due to conflicting colors

Solution

  1. Step 1: Understand config merging order

    Local config overrides preset values when keys conflict, so local primary color '#ff0000' overrides preset '#00ff00'.
  2. Step 2: Determine final color for bg-primary

    The div uses the local config color '#ff0000' (red).
  3. Final Answer:

    #ff0000 (red) from local config -> Option A
  4. Quick Check:

    Local config overrides preset colors [OK]
Hint: Local theme colors override preset colors [OK]
Common Mistakes:
  • Assuming preset colors override local config
  • Thinking conflicting keys cause errors
  • Believing class won't apply without explicit import
4. You added a preset in tailwind.config.js but your styles from the preset are not applying. What is the most likely mistake?
medium
A. Using preset instead of presets in config
B. Forgetting to export the preset module with module.exports
C. Not installing Tailwind CSS in the project
D. Adding presets inside the theme object

Solution

  1. Step 1: Check common config mistakes

    Using preset (singular) instead of presets (plural) means Tailwind ignores the preset array.
  2. Step 2: Validate other options

    Forgetting to export the preset module with module.exports is possible but less common; C and D are unrelated to preset loading.
  3. Final Answer:

    Using preset instead of presets in config -> Option A
  4. Quick Check:

    Correct property name is 'presets' [OK]
Hint: Use 'presets' plural, not 'preset' singular [OK]
Common Mistakes:
  • Misspelling 'presets' as 'preset'
  • Placing presets inside wrong config section
  • Not exporting preset module properly
5. You want to share a preset that includes custom fonts and colors across three projects. Which approach ensures all projects use the preset and can override colors if needed?
hard
A. Use Tailwind's CDN link with custom fonts and colors embedded
B. Copy the preset config file into each project and import it manually in CSS files
C. Write the preset config directly inside each project's tailwind.config.js without sharing
D. Create a separate npm package with the preset and add it in each project's presets array; override colors locally as needed

Solution

  1. Step 1: Identify best sharing method

    Creating a separate npm package for the preset allows easy reuse and updates across projects.
  2. Step 2: Confirm override capability

    Adding the preset in presets array lets each project override colors locally without changing the shared preset.
  3. Final Answer:

    Create a separate npm package with the preset and add it in each project's presets array; override colors locally as needed -> Option D
  4. Quick Check:

    npm package + presets array + local overrides = best practice [OK]
Hint: Use npm package for preset + local overrides [OK]
Common Mistakes:
  • Copying preset files manually causing duplication
  • Embedding config directly without sharing
  • Using CDN which can't share config presets
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