Performance: Icon sizing and colors
This affects page load speed and rendering performance by impacting CSS complexity and paint times when icons are resized or recolored inefficiently.
<i class="bi bi-star fs-3 text-danger"></i>
<i class="bi bi-star" style="font-size: 50px; color: #ff0000;"></i>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inline styles for icon size and color | Minimal DOM nodes | Triggers 1 reflow per icon | High paint cost due to unique styles | [X] Bad |
| Bootstrap utility classes for size and color | Minimal DOM nodes | Single reflow for all icons | Low paint cost due to shared styles | [OK] Good |
fs-* classes to control font size, which affects icon size.fs-*, where * is a number like 1, 2, 3, etc.text-danger?text-danger for red color.text-danger applies a red color to text or icons.<i class='bi bi-check fs-1 text-successs'></i>. What is the problem?text-successs has an extra 's' and is invalid.bi-check is a valid icon, fs-1 is valid for large size, aria-label is optional but recommended.bi-info-circle is correct icon name; fs-3 is medium size.text-primary is blue color; aria-label='Info icon' provides accessible label.<i class='bi bi-info-circle fs-5 text-info' aria-label='Info icon'></i> uses fs-5 (small size) and text-info (lighter blue). <i class='bi bi-info fs-3 text-primary' aria-hidden='true'></i> misses accessible label and uses aria-hidden. <i class='bi-info-circle fs-3 text-primary' aria-label='Info icon'></i> misses bi class prefix.Pass the test and this pattern moves unknown