New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature Request] add scopeId
option
#110
Comments
i think it is different with #96, think about this: export default App() {
return <>
<h1>hello<h1>
<style>{`
h1 { font-size: 100px; }
`}</style>
</>
} I want to apply the <h1 data-scope-id>hello<h1> h1[data-scope-id] {
font-size: 100px;
} And for AST transformer, add a new html/JSX attr is very easy, but rewriting class name is very complex(consider lots of edge cases). |
As I have known, vue sfc is using |
So the question is, how do you specify how this id is used? There seem to be several different ways it's commonly done:
Some of these also seem to have a way of opting out, e.g. A nice thing about CSS modules is that it is somewhat of a "standard", and it's not tied to a specific library or framework, so multiple build tools can implement it. Is there such a spec for this type of scoped styles too, or do we basically have to invent our own yet again? It would be nice if, say, build tools could swap over to Parcel CSS and still work with Vue and Svelte without also changing the template compiler. But I'm not sure that's possible unless we implement all of the ways listed above... |
I think this could be solved by the custom transform API I'm working on (#363). |
The custom transform API is now released. See https://lightningcss.dev/transforms.html. Hopefully you could now solve this case with that. If this becomes a common enough ask, and we can define the way it should work across tools, we could implement it in Lightning CSS core, but now at least it is possible to build yourself. |
thanks a lot! |
This feature is vary useful for
Inline Style
in UI component with scope:For example:
then we can inject the
data-***
attr into elements of current component:The text was updated successfully, but these errors were encountered: