Performance: Extending default theme values
MEDIUM IMPACT
Extending default theme values affects CSS bundle size and rendering performance by adding more styles to process.
const defaultTheme = require('tailwindcss/defaultTheme'); module.exports = { theme: { extend: { colors: { customRed: '#f00', customBlue: '#00f' } } } }
module.exports = {
theme: {
colors: {
red: '#f00',
blue: '#00f',
green: '#0f0',
yellow: '#ff0',
purple: '#800080',
orange: '#ffa500',
pink: '#ffc0cb',
teal: '#008080',
lime: '#00ff00',
cyan: '#00ffff',
// many more custom colors added here
}
}
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Override entire theme colors | No extra DOM nodes | No reflows triggered | High paint cost due to large CSS | [X] Bad |
| Extend theme colors selectively | No extra DOM nodes | No reflows triggered | Lower paint cost with smaller CSS | [OK] Good |