2022-03-23
1982
#nextjs
Marie Starck
99501
Mar 23, 2022 â‹… 7 min read

The best styling options for Next.js

Marie Starck Marie Starck is a fullstack software developer. Her specialty is JavaScript frameworks. In a perfect world, she would work for chocolate. Find her on Twitter @MStarckJS.

Recent posts:

Exploring Nushell, A Rust Powered, Cross Platform Shell

Exploring Nushell, a Rust-powered, cross-platform shell

Nushell is a modern, performant, extensible shell built with Rust. Explore its pros, cons, and how to install and get started with it.

Oduah Chigozie
Apr 23, 2024 â‹… 6 min read
Exploring Zed, A Newly Open Source Code Editor Written In Rust

Exploring Zed, an open source code editor written in Rust

The Zed code editor sets itself apart with its lightning-fast performance and cutting-edge collaborative features.

Nefe Emadamerho-Atori
Apr 22, 2024 â‹… 7 min read
Implementing Infinite Scroll In Next Js With Server Actions

Implementing infinite scroll in Next.js with Server Actions

Infinite scrolling in Next.js no longer requires external libraries — Server Actions let us fetch initial data directly on the server.

Rahul Chhodde
Apr 19, 2024 â‹… 10 min read
Integrating Django Templates With React For Dynamic Webpages

Integrating Django templates with React for dynamic webpages

Create a dynamic demo blog site using Django and React to demonstrate Django’s server-side functionalities and React’s interactive UI.

Kayode Adeniyi
Apr 18, 2024 â‹… 7 min read
View all posts

6 Replies to "The best styling options for Next.js"

  1. I think you make a mistake in the cons to of css modules.

    Potential styling conflicts when used in large projects.

    Not really css are managed by JavaScript for give scope (always have a hash to prevent collision)

    No dynamic styling (e.g., based on a status like loading, error, success, etc.)
    This would be implemented with data-attributes.

    And another pro is that CSS Modules is more fast than another styles solutions.

    1. I… totally did. 🤦‍♀️ Thank you for bringing that to my attention. I will get that fixed.

      As for data-attributes, I couldn’t find a good and easy example. The best I could find was Sasha’s guide to write CSS components using data attributes (https://sacha.me/articles/css-data-components). Compared to Emotion where you can just pass in props and any conditional styling you want, using data-attributes sounds complicated.

      1. Nothing complicated about using data attributes. CSS (especially SCSS) modules are boss. Never understood the whole appeal of “single file components”. One tab for html/jsx another for css and you’re clean and in business. No need to get out of sync with the rest of the web and constantly change to a new hipper syntax each year. Have you thought of the headaches of opening up a tailwind or css-in-js site 5 years from now when whatever library du jour you used is long defunct and a security liability?

        “`css
        div[data-invalid] {
        color: red;
        }

        div:not([data-invalid]) {
        display: none;
        }
        “`

        “`javascript
        Name is a required field
        “`

    2. Hi Anthony,

      Thanks for reading this blog post and catching this error! We’ve updated the post with the corrected information.

Leave a Reply