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.

Really like Vue's solution for css, how about a similar one like this for React?

See original GitHub issue

Do you want to request a feature or report a bug? feature

What is the expected behavior? So I really like Vue’s solution for css, how about a similar one like this for React?

// App.js
import Scoped from "scoped-css"
import style from "./App.css"

const App = () =>
<Scoped style={style}>
   <div className="App">
        <div className="header">
          <h2>Welcome to React</h2>
        </div>
        <p className="intro">
          To get started...
        </p>
      </div>
</Scoped>

//App.css
.App { ... }
.header { ... }
.intro { ... }

CSS will apply to elements of the current component only, and parent component’s styles will not leak into child components.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

13reactions
lorenzorapetticommented, Jun 16, 2018

I think that styled-jsx and CSS Modules already achieve what you’re thinking of.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The CSS-in-React Landscape
Vue has style tags built right into Single File Components. Same with Svelte. Angular also has a built-in component-scoped styles solution.
Read more >
Vue vs React in 2022 - Comparison of Two Most Popular ...
Vue.js and React.js are two popular frontend frameworks in the developer world, switching top spot on the podium each year in the categories ......
Read more >
Vue vs React: What is The Best JS Technologies in 2023?
Vue and React are considered the best Javascript framework and library. So it comes as no surprise that many companies use them in...
Read more >
I created the exact same app in React and Vue. Here are ...
You'll see that their structures are similar as well. The key difference so far is that the React app has two CSS files,...
Read more >
JavaScript Tools: A React and Vue Comparison
Initially, JSX could be a bit of a learning curve for a typical developer. Although JSX is a different approach, it is very...
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