Performance: Why theme customization is needed
Theme customization affects the CSS bundle size and rendering speed by controlling which styles are generated and used.
/* Tailwind theme customization in tailwind.config.js */ module.exports = { content: ['./src/**/*.{html,js}'], theme: { extend: { colors: { primary: '#1D4ED8', secondary: '#9333EA' }, fontFamily: { sans: ['Inter', 'sans-serif'] } } } };
/* Tailwind default theme without customization */ @tailwind base; @tailwind components; @tailwind utilities; /* Using many default colors and fonts without pruning */
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Default Tailwind theme with many colors/fonts | Low | Low | High due to large CSS | [X] Bad |
| Customized Tailwind theme with limited colors/fonts | Low | Low | Low due to small CSS | [OK] Good |
extend option allows adding new styles while keeping defaults.extend adds new colors without removing default ones.bg-primary apply?{
theme: {
extend: {
colors: {
primary: '#1DA1F2'
}
}
}
}primary with value #1DA1F2.bg-primary uses the primary color defined in the config.{
theme: {
fontFamily: {
custom: ['Comic Sans MS', 'cursive']
}
}
}fontFamily directly, replacing all default fonts.extend inside theme.72 with value 18rem but keep all default spacing sizes. Which config snippet correctly does this?extend inside theme.theme.extend.spacing to add 72: '18rem' while keeping defaults.Pass the test and this pattern moves unknown