Back to results for “Layouts”
Next.js › Styling in Next.js (CSS Modules, Tailwind & Styled Components)

How would you organize global styles versus component specific styles in a large Next.js application?

Intermediate

Answer

You typically place truly global styles, like base typography and CSS variable definitions, in a single global stylesheet imported once in your root layout, while keeping component specific styling scoped locally using CSS Modules or Tailwind utility classes directly on each individual component.
// app/layout.js
import './globals.css';

export default function RootLayout({ children }) {
  return <html><body>{children}</body></html>;
}
Real-world example A large e-commerce application keeps its base typography and color variables in a single global stylesheet, while every individual component, like product cards and buttons, manages its own specific styling locally.

Common follow-ups: Where is the best place to import global CSS in the App Router?;How do you prevent global styles from unintentionally affecting specific components?