Search code examples
cssreactjsnext.jsdirectory-structurereact-css-modules

Should i import css into a next page?


I want to ask if css can and should be imported into next pages. is the page structure below acceptable, or what is the standard practice

/pages
    /home
        index.js
        index.module.css
    /cart
        index.js
        index.module.css

am i to move all the elements of a page that require styling into the components folder


Solution

  • I would put the styles in their own folder like this:

    /pages
        /home
            index.js
        /cart
            index.js
    /styles
        home.module.css
        cart.module.css
    

    And then import with import homeStyles from '../styles/home.module.css.