Performance: Button component patterns
This affects page load speed and interaction responsiveness by how button styles and behaviors are implemented.
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded shadow-md transition-colors duration-150">Click me</button><button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded inline-block" style="box-shadow: 0 0 10px rgba(0,0,0,0.5); transition: all 0.5s ease;">Click me</button>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inline styles with complex shadows and transitions | Low | 0-1 per hover | High (multiple paints) | [X] Bad |
| Tailwind utility classes for shadows and transitions | Low | 0-1 per hover | Low (single paint) | [OK] Good |
| Inline styles for disabled state | Low | 2 per state change | Medium | [X] Bad |
| Tailwind classes for disabled state | Low | 1 per state change | Low | [OK] Good |
| Inline SVG styles inside button | Medium (extra nodes) | 0 | Medium | [X] Bad |
| Tailwind classes for SVG sizing and spacing | Medium (extra nodes) | 0 | Low | [OK] Good |
cursor-pointer changes the mouse cursor to a hand icon, signaling clickability.text-center centers text, bg-gray-100 sets background color, and p-4 adds padding, none indicate clickability.bg-blue-500 is a valid blue background, text-white sets white text, and rounded adds small rounded corners.blue-bg and white-text are not Tailwind classes; bg-blue is incomplete; rounded-full makes fully round shape but text is black, not white.<button class='bg-green-600 hover:bg-green-700 text-white font-bold py-2 px-4 rounded'>Submit</button>
bg-green-600 sets a green background; hover:bg-green-700 makes it darker green on hover.text-white sets white text, font-bold makes text bold, rounded adds rounded corners.<button class='bg-red-500 hover:bg-red-600 text-white rounded p-3 disabled:opacity-50 disabled:pointer-events-none' disabled>Delete</button>
disabled attribute disables the button, so hover styles do not apply when disabled.hover:bg-red-600 works only when button is enabled; when disabled, hover has no effect.w-full makes button full width; md:w-auto overrides width to auto on medium screens and up.px-6 py-3 add padding, bg-indigo-600 sets background, text-white sets text color, rounded rounds corners.Pass the test and this pattern moves unknown