Performance: Tailwind CSS integration
This affects page load speed by adding CSS bundle size and rendering performance by how styles are applied and updated.
/* tailwind.config.js with content paths configured for purge */ import './globals.css'; // contains @tailwind directives export default function Page() { return <div className="text-center font-bold text-xl">Hello World</div>; }
import 'tailwindcss/tailwind.css'; export default function Page() { return <div className="text-center font-bold text-xl">Hello World</div>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Full Tailwind CSS import without purge | Minimal DOM impact | 0 reflows from CSS | High paint cost due to large CSS | [X] Bad |
| Tailwind CSS with JIT purge enabled | Minimal DOM impact | 0 reflows from CSS | Low paint cost with small CSS | [OK] Good |
pages/_app.js for pages router or app/layout.js for app router.export default function Button() {
return <button className="text-red-500 hover:text-blue-500">Click me</button>;
}text-red-500 which sets text color red initially, and hover:text-blue-500 which changes text color to blue on hover._app.js or layout.js.md: applies styles at medium screens and above.bg-green-500. To override with blue on medium+, use md:bg-blue-500.Pass the test and this pattern moves unknown