Performance: Why Remix supports multiple styling approaches
This affects page load speed and rendering performance by allowing developers to choose styling methods that best fit their app's needs and optimize critical rendering paths.
import styles from './Component.module.css'; export default function App() { return <div className={styles.container}>Hello Remix</div>; }
import './global.css'; export default function App() { return <div className="container">Hello Remix</div>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Global CSS | Low (no extra DOM nodes) | Multiple reflows if CSS changes | High due to large CSS size | [X] Bad |
| CSS Modules | Low | Single reflow on load | Moderate, scoped CSS | [OK] Good |
| Inline Styles | Low | Multiple paints on style changes | High paint cost, no caching | [X] Bad |
| CSS-in-JS | Low | Single reflow, optimized paint | Low to moderate, cached CSS | [OK] Good |
links export?links function must return an array of objects with rel and href keys.rel: 'stylesheet' and href.import { useState } from 'react';
export default function Button() {
const [active, setActive] = useState(false);
return (
setActive(!active)}
>
Click me
);
}active state starts as false.active is false, backgroundColor is 'gray'.links function that tries to add a stylesheet?export function links() {
return { rel: 'stylesheet', href: '/main.css' };
}links function must return an array of link descriptor objects.links export and CSS-in-JS inside components for scoped styles.links function for global CSS and using CSS-in-JS inside components correctly describes combining global CSS with component-level CSS-in-JS.Pass the test and this pattern moves unknown