What is the globals.css file?
app/globals.css is the conventional global stylesheet in a Next.js App Router project, created by create-next-app and imported in the root layout. It holds the Tailwind import, CSS resets, design tokens as CSS variables, base element styles and dark mode variables that apply to every page.
What usually goes in it
@import "tailwindcss";(Tailwind v4) and@themetokens.- CSS custom properties:
:root { --background: #fff; --foreground: #111; }and a dark variant. - Base styles:
bodyfont, background,color-scheme. - Small global utilities and third-party CSS imports.
Rules
- The name is a convention, not special. What matters is importing it in
app/layout.tsx. - In the App Router, global CSS can be imported anywhere, but importing it once in the root layout keeps ordering predictable.
- Styles are global: keep component-specific styles in CSS Modules or Tailwind classes to avoid conflicts.
- In the Pages Router, global CSS can only be imported in
pages/_app.tsx.
Performance
It loads on every route, so keep it lean. Large component libraries' CSS can be imported only in the layouts or pages that need them, since CSS is chunked per route.
Smooth scrolling note (Next.js 16)
If you set scroll-behavior: smooth on html here, Next.js no longer overrides it during navigation. Add data-scroll-behavior="smooth" to <html> if you want Next.js to switch to instant scrolling during route changes, as it did before.
Code example
1/* app/globals.css */2// @import "tailwindcss";3//4// :root {5// --background: #ffffff;6// --foreground: #0b1020;7// color-scheme: light;8// }9//10// .dark {11// --background: #0b1020;12// --foreground: #f8fafc;13// color-scheme: dark;14// }15//16// @theme inline {17// --color-background: var(--background);18// --color-foreground: var(--foreground);19// }20//21// body { background: var(--background); color: var(--foreground); }2223// app/layout.tsx24import "./globals.css";2526export default function RootLayout({ children }: { children: React.ReactNode }) {27 return (28 <html lang="en" data-scroll-behavior="smooth">29 <body className="bg-background text-foreground antialiased">{children}</body>30 </html>31 );32}
Practice this question
Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the Next.js set.