0
0
NextJSframework~10 mins

Global CSS in NextJS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import a global CSS file in a Next.js app.

NextJS
import '[1]';
Drag options to blanks, or click blank then click option'
A'./utils/helpers.css'
B'./components/Button.css'
C'./pages/index.css'
D'./styles/global.css'
Attempts:
3 left
💡 Hint
Common Mistakes
Importing CSS files inside components instead of _app.js
Using incorrect relative paths
Trying to import CSS files outside the styles folder
2fill in blank
medium

Complete the code to create a custom App component that applies global CSS in Next.js.

NextJS
export default function MyApp({ Component, pageProps }) {
  [1]
}
Drag options to blanks, or click blank then click option'
Areturn <div>{Component}</div>;
Breturn <Component />;
Creturn <Component {...pageProps} />;
Dreturn pageProps;
Attempts:
3 left
💡 Hint
Common Mistakes
Not passing pageProps to Component
Wrapping Component incorrectly
Returning pageProps directly instead of JSX
3fill in blank
hard

Fix the error in this _app.js file by completing the import statement for global CSS.

NextJS
import [1] from 'next/app';
import './styles/global.css';

export default function MyApp({ Component, pageProps }) {
  return <Component {...pageProps} />;
}
Drag options to blanks, or click blank then click option'
AApp
BReact
CuseState
DComponent
Attempts:
3 left
💡 Hint
Common Mistakes
Importing React instead of App
Using wrong import names
Not importing anything from 'next/app'
4fill in blank
hard

Fill both blanks to correctly import and use global CSS in a Next.js app.

NextJS
import [1] from 'next/app';
import [2];

export default function MyApp({ Component, pageProps }) {
  return <Component {...pageProps} />;
}
Drag options to blanks, or click blank then click option'
AApp
B'./styles/global.css'
C'./components/button.css'
DReact
Attempts:
3 left
💡 Hint
Common Mistakes
Using component CSS instead of global CSS
Wrong import names or paths
Missing curly braces for named imports
5fill in blank
hard

Fill all three blanks to create a working _app.js file that applies global CSS in Next.js.

NextJS
import [1] from 'next/app';
import [2];

export default function [3]({ Component, pageProps }) {
  return <Component {...pageProps} />;
}
Drag options to blanks, or click blank then click option'
AApp
B'./styles/global.css'
CMyApp
DReact
Attempts:
3 left
💡 Hint
Common Mistakes
Naming the function incorrectly
Not importing global CSS properly
Missing or wrong import from 'next/app'