From the course: Master Next.js: Elaborate Hands-On Web Development, React Basics, Advanced Next.js, and Deployment
Unlock this course with a free trial
Join today to access over 25,200 courses taught by industry experts.
Global styling with Next.js
From the course: Master Next.js: Elaborate Hands-On Web Development, React Basics, Advanced Next.js, and Deployment
Global styling with Next.js
But if you want to add a global style that would basically affect everything and not just one component, it would be annoying to redo the same component layout on each and every single page. To load global CSS, what we could do actually is we could create in our pages an app.js file, and the default export of that is a top-level React component that would wrap all the pages in our applications. Then we could use that to add global styles. So in our pages, we're going to add another file at the root of pages. And it's going to be next to the index. And it's going to be underscore app.js. Oops, not ks. And here, OK, very good. And here we're going to do an export default function app. And we'll have a component. Oops, component. Components, page props, and we're going to return the components and the page props here. The underscore app is really what we're using as a top-level React component. And to get this really to work, we're going to have to restart the server. So we're going to…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
-
(Locked)
Download the CSS starter kit project from Next.js official7m 27s
-
(Locked)
How images optimize with Next.js5m 31s
-
(Locked)
Scripts and header data and props with Next.js6m 58s
-
(Locked)
CSS modules and Next.js optimizations with layout7m 12s
-
(Locked)
Global styling with Next.js4m 47s
-
(Locked)
Customizing utility styles with Next.js9m 55s
-
(Locked)
Metadata for SEO and social media with Next.js6m 43s
-
(Locked)
Writing dynamic layout components with Next.js11m 31s
-
(Locked)
How to use children and props in React and Next.js10m 54s
-
(Locked)
-
-
-