Optimize your development workflow using utility-first class composition and configuration patterns.
Maximize productivity with Tailwind's atomic classes while maintaining maintainable, consistent styling.
Start with your smallest screen size, then scale up with responsive modifiers.
<div class="bg-blue-500 text-white p-4 rounded-md
md:bg-green-500
lg:text-xl"
href="/#">Responsive Component</code>
Use breakpoints like sm, md, lg, xl to target different screen sizes effectively.
<div class="hidden sm:flex"
sm:block
lg:hidden">Responsive</code>
Extend or override default settings in your tailwind.config.js file.
module.exports = {
theme: {
extend: {
colors: {
primary: '#0070f3'
},
fontFamily: {
sans: ['Inter', 'sans-serif']
}
}
}
}
Improve build times and reduce CSS size using these expert strategies for production-grade projects.
Enable Just-In-Time compiler for significantly faster rebuilds during development.
/** @type {import('tailwindcss').Config} */
module.exports = {
mode: 'jit',
content: ['./src/**/*.{js,ts,jsx,tsx}'],
theme: {}
}
Configure content paths to remove unused classes from production builds.
purge: {
content: ['src/**/*.tsx', 'public/index.html'],
options: {
whitelistPatterns: [/^data-/]
}
}
Create conditional styles for complex UI state combinations using custom variants.
variants: [
['group-hover', 'hover']
]
Demonstration of a reusable base card component with customizable variants
<div class="bg-white border border-gray-200
rounded-xl p-6
shadow-sm hover:shadow-md
transition-shadow
dark:bg-gray-900 dark:border-gray-800"
aria-labelledby="card-title">
<div class="flex justify-between">
<h3 id="card-title" class="text-lg font-semibold">...</h3>
<span class="text-sm text-gray-500">...</span>
</div>
<p class="mt-2 text-gray-600">...</p>
</div>
Balance customization and maintainability by organizing your configuration effectively.
Add custom colors, fonts, or spacing values to extend the default theme.
extend: {
spacing: {
'128': '32rem'
},
zIndex: {
'100': '100'
}
}
Organize plugins logically and minimize dependency bloat.
plugins: [
require('@tailwindcss/typography'),
require('@tailwindcss/forms'),
function({ addVariant }) {
addVariant('children', '> *');
}
]
Keep configuration modular by splitting into multiple preset files.
require('./tailwind-presets/core'),
require('./tailwind-presets/forms')