Performance: Overriding color palette
This affects the CSS bundle size and rendering speed by changing how colors are loaded and applied in the browser.
module.exports = {
theme: {
colors: {
primary: '#1a202c',
secondary: '#2d3748',
accent: '#4a5568'
}
}
}module.exports = {
theme: {
extend: {
colors: {
primary: '#1a202c',
secondary: '#2d3748',
accent: '#4a5568',
// many custom colors added here
custom1: '#123456',
custom2: '#654321',
custom3: '#abcdef',
custom4: '#fedcba'
}
}
}
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Many custom colors in Tailwind config | Minimal | 0 | High due to large CSS | [X] Bad |
| Minimal color overrides in Tailwind config | Minimal | 0 | Low CSS paint cost | [OK] Good |
brandBlue without removing default colors in tailwind.config.js?extend inside themeextend inside theme.extend: { colors: { brandBlue: '#1DA1F2' } }.tailwind.config.js snippet, what background color will bg-brandBlue apply?module.exports = {
theme: {
extend: {
colors: {
brandBlue: '#1DA1F2'
}
}
}
}brandBlue with hex #1DA1F2.bg-brandBlue uses this custom color as background.module.exports = {
theme: {
colors: {
brandRed: '#E02424'
}
}
}colors replaces all default colors.extend: { colors: { brandRed: '#E02424' } } inside theme to add without removing.brandGreen and also change the default blue color to #005f73. Which config snippet correctly does this?theme.extend.colors to add brandGreen without removing defaults.blue, use extend.colors.blue: '#005f73'; this overrides it while keeping other defaults.extend.colors: { brandGreen: '#0a9396', blue: '#005f73' }.Pass the test and this pattern moves unknown