0
0
Tailwindmarkup~20 mins

Preset sharing across projects in Tailwind - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Tailwind Preset Pro
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
How to share Tailwind presets across multiple projects?
You want to reuse a Tailwind CSS preset configuration in several projects. Which approach correctly shares the preset without duplicating code?
ACopy the preset config file manually into each project folder.
BPublish the preset as an npm package and install it in each project.
CUse a CDN link to load the preset CSS directly in each project.
DWrite the preset styles inline in each HTML file.
Attempts:
2 left
💡 Hint
Think about how code reuse and version control work best in JavaScript projects.
📝 Syntax
intermediate
2:00remaining
Correct syntax to extend Tailwind config with a shared preset
Given a shared preset package named @myorg/tailwind-preset, which tailwind.config.js snippet correctly extends it?
Tailwind
module.exports = {
  presets: [/* ??? */],
  theme: {
    extend: {
      colors: {
        primary: '#123456'
      }
    }
  }
}
Apresets: require('@myorg/tailwind-preset'),
Bpresets: ['@myorg/tailwind-preset'],
Cpresets: [import '@myorg/tailwind-preset'],
Dpresets: [require('@myorg/tailwind-preset')],
Attempts:
2 left
💡 Hint
Remember how Node.js requires modules in config files.
rendering
advanced
2:00remaining
What is the visual result of using a shared preset with extended colors?
You have a shared preset that defines colors: { brand: '#ff0000' }. Your project extends it with colors: { brand: '#00ff00' }. What color will the class text-brand apply?
AGreen (#00ff00) from the project extension
BRed (#ff0000) from the preset
CNo color applied, class is undefined
DBoth colors applied, resulting in a gradient
Attempts:
2 left
💡 Hint
Think about how Tailwind merges theme extensions.
selector
advanced
2:00remaining
How to customize Tailwind variants in a shared preset?
You want your shared preset to add a custom variant group-hover for a utility. Which snippet correctly adds this variant inside the preset's tailwind.config.js?
Tailwind
module.exports = {
  variants: {
    extend: {
      backgroundColor: [/* ??? */]
    }
  }
}
AbackgroundColor: ['active'],
BbackgroundColor: 'group-hover',
CbackgroundColor: ['group-hover'],
DbackgroundColor: ['hover', 'focus'],
Attempts:
2 left
💡 Hint
Variants are arrays of strings representing states.
accessibility
expert
3:00remaining
Ensuring accessible focus styles with shared Tailwind presets
Your shared preset removes default focus outlines for buttons but you want to keep accessible focus indicators in all projects. What is the best way to handle focus styles in the preset?
ADefine custom focus-visible styles using Tailwind’s <code>focus-visible</code> variant in the preset.
BRemove all focus styles in the preset and rely on browser defaults.
CUse <code>outline-none</code> globally in the preset to remove outlines everywhere.
DAdd JavaScript to simulate focus outlines instead of CSS.
Attempts:
2 left
💡 Hint
Accessible focus means visible outlines only when keyboard users focus elements.