skip to Main Content

I am using nextjs 14 , and i want to know that how to include ‘style.css’ and other custom css files in nextjs project ?

My current file structure is

my-project/
├── components/
│   ├── footer.tsx
│   ├── header.tsx
│   └── page.tsx
├── pages/
│   ├── _app.tsx
│   └── index.tsx
├── styles/
│   ├── globals.css
│   └── styles.css
├── public/
│   └── image1.jpg
├── package.json
├── next.config.js
└── tsconfig.json

2

Answers


  1. The import syntax would be as usual.

    You can simply import using CSS file path.

    import 'path/to/styles.css';

    Login or Signup to reply.
  2. there is no need to add one CSS file to another CSS file like we import components in React.js.
    You can add as many CSS files separately and they will work as expected.

    Open your _app.tsx file in the pages directory. add this CSS files like this

    import '../styles/globals.css'; // Import global styles
    import '../styles/styles.css'; // Import additional custom styles
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search