question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using SASS styles inside <style jsx>

See original GitHub issue

Is that possible? I am used to SASS and want to use it in my next app. Currently, I have this code:

p {
    color: red;
}

p.span {
  color: blue;
}

And I wanna make it like this:

p {
    color: red;

    &.span {
      color: blue;
    }
}

If I do that, it doesn’t throws errors, but the indented style gets ignored.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:13

github_iconTop GitHub Comments

2reactions
HansUXdevcommented, May 22, 2019

Any update on this?

Or atleast using postcss plugins for css nesting and container-query?

With javascript functions and variables, we don’t really need css vars (and the ugly syntax) or mixins but nesting and container query support would be very nice.

2reactions
fredshcommented, Feb 21, 2018

Hello, not sure this is the right place for this question. I am using styled jsx with the sass plugin. Works well but I have encountered a small issue trying to use js variable inside the style. It seems that simple variable use works for simple values, but not when used in more complex case like parameter of a mixin. Below is a small example of what I am trying to do. The color is applied correctly but the media query will not work as expected (always evaluates to true). ` const bp = ‘medium’ const col = ‘yellow’

    <style jsx>{`
      @import 'styles/css/foundation.scss';
      .layout{
        width: 100%;
        @include breakpoint($bp) {
          max-width: 80%;
          background-color: ${col};
        }
      }
      `}</style>

`

I have seen this in the readme

Plugins won’t transform expressions

If I understand correctly, what I want to do is currently not supported right? Is there any plan to support this in the future? And if I wanted to help support this, where should I look? By the way, thanks for the great work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Use Sass and Styled Components in a React JS ...
Awesome! Let's start styling our component! Inside the Sass folder, create a new folder called “components”. This folder will hold the styles for...
Read more >
How to style with SASS/SCSS in React ? - GeeksforGeeks
Introduction: We can use SASS in React using a package called node-sass. Using node-sass we can just create sass files and use them...
Read more >
CSS in React: 5 ways w/ sass + styled components + modules
In this video we will take a look at the different ways to utilize CSS in a React application. We will learn about...
Read more >
React Sass Styling - W3Schools
Sass is a CSS pre-processor. Sass files are executed on the server and sends CSS to the browser. You can learn more about...
Read more >
Configuring styled-jsx with scss in Next.js | by Bob Fanger
Next.js has sass support is built-in, but this doesn't extend to the styling inside styled-jsx tags. The sass syntax is not working, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found