Next.js supports global CSS, CSS Modules, and utility-first frameworks like Tailwind CSS—often enabled in create-next-app templates.
CSS Modules
// button.module.css
.button { padding: 0.5rem 1rem; }
// Button.tsx
import styles from './button.module.css';
export function Button() {
return <button className={styles.button}>Click</button>;
}
Class names are scoped locally—no accidental global collisions.
Tailwind
<button className="rounded-lg bg-slate-900 px-4 py-2 text-white hover:bg-slate-800">
Save
</button>
Utility classes speed prototyping; extract components when patterns repeat.
App Router colocation
Keep styles next to the component or route they serve. Global tokens (fonts, colors) live in root layout.tsx or globals.css.
Self-check
- How do CSS Modules prevent naming clashes?
- When should you extract a Tailwind button into a component?