Skip to content

Rules nesting #397

Open
Open

Description

@velosipedist

As the working draft were implemented in most of the browsers, it would be great to support the nesting here as well.

.demo {
  & .circle {
    opacity: .25;
    filter: blur(25px);
  }
  > .square {
    color: red;
  }
}

Activity

  1. pascalduez commented on Aug 18, 2023

    @pascalduez

    Hello,

    I was curious so just did a quick test, seems so nesting is currently supported?
    https://codesandbox.io/s/jovial-neco-whpg94?file=/src/Test.module.css

    The compiled CSS properly keep the nesting, classes are scoped.

    At least with this implementation, which I believe is create-react-app, css-loader etc.

  2. JuanPastenCastillo commented on Jun 21, 2024

    @JuanPastenCastillo

    At least, for now you can use it this way on Nextjs:

    // Component.tsx
    import styles from "./Styles.module.css"
    
    export const CSS_Modules = () => {
      return (
        <div className={styles.css}>
          <h2 className={styles.h2}>Some H2</h2>
    
          <h2>Other h2</h2>
    
          <h2>More h2!</h2>
        </div>
      )
    }
    /* Styles.module.css */
    .css {
      border: 2px solid black;
    
      .h2 {
        border: 2px solid crimson;
        color: red;
      }
    
      &.css > :nth-child(2) {
        border: 2px solid green;
        color: green;
      }
    
      &.css :nth-child(3) {
        border: 2px solid yellow;
        color: yellow;
      }
    }

    Result:

    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions