Bug: Global styles included in _app.js are placing at the end of <head>
See original GitHub issueBug report
Describe the bug
Global styles included in _app.js
are placed at the end of head
tag. They can overwrite component styles.
To Reproduce
Just import any global styles in _app.js
and they will appear at the end of head
tag.
Expected behavior
I expected to see the next appearing order of head
tags in next.js:
- Tags included in
_document.js
(works 👍) - Tags included in
_app.js
(works 👍) - Global styles included in
_app.js
(not working 😡) - Tags of pages (works 👍)
Screenshots
- OS: [macOS]
- Version of Next.js: [9.2.1]
Issue Analytics
- State:
- Created 4 years ago
- Reactions:9
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Should global css be put in each component or the root ...
I'd import your font.css file when and where you use it (but not exactly the way you suggest, see below) and not just...
Read more >Global vs. Local Styling In Next.js - Smashing Magazine
The answer is surprisingly simple — to write well-structured CSS that balances global and local styling concerns.
Read more >Styling in React: 5 ways to style React apps - LogRocket Blog
Learn about styling React components with inline styling, styled-components, CSS modules, Tailwind CSS, and Sass and CSS style sheets.
Read more >Working with CSS in Nuxt.js - Red Onion
Main topics in this article are preprocessors, autoprefixing, CSS Source Maps , global styles and how to add a separate CSS file to...
Read more >How to add stylesheet in Next.js ? - GeeksforGeeks
In this post, we have used all the CSS files present in styles folder, components/Navbar.js, pages/_app.js and pages/index.js. Syntax: To import ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Global styles should be placed in _document, especially something like normalize.css. On the other hand it’s next/head expected behavior, adds tags end of the tags in document head. Can you elaborate why you want to achieve this.
This also conflicts with sass imports and compilation order. Inside of modules you are not able to use variables defined in globals styles.