-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Change how you write global styles inside a component #6186
Comments
|
It's the same feature. Also, I want to be able to write 2 style tags inside the same component (one for global and one for scoped styles). |
+1 for this. It would be a lot of help for component libraries as they do not have to scope their styles so that users can modify the component CSS easily. It would also improve performance. Multiple style tags would also be a plus. |
+1 for this. I would also need this feature for global theming of my website. |
A workaround:
|
Hi <script></script>
<template></template>
<style></style> So I think it's good to just have 2 style tags at the bottom of the template. So we don't break any rules and keep the main focus on the script and the template👼. |
I fully agree with your request. My proposal is a workaround to keep working while your request is being developed by the Svelte Team. As soon as the dev is ready, all I have to do is remove the By the way, it's worth saying that, what you request, exists in VUE JS where you can add the scoped keyword to your style tag to make all the content scoped : see https://vue-loader.vuejs.org/guide/scoped-css.html It's also worth saying that the :global() modifier that can be used on a per-selector basis is worth keeping as it allows for fine-tuning necessary in some cases. |
Sorry, my bad🙏. I didn't see this👨🦯:
I took that you were requesting the feature.
Yeah, Vue has the
I do not really agree with this because of all of the negative things that I said in this issue and also:
My guesses are that they probably going to keep the |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been closed as it was previously marked as stale and saw no subsequent activity. |
I think it is important to keep this issue open. Merging "Option to disable style encapsulation #5492" with this issue doesn't seem particularly beneficial in my opinion. Personally, I find style encapsulation less desirable in Svelte, as it can make the code less readable. Looking ahead, I hope to see a future feature that gives users the flexibility to disable style encapsulation. While I understand the reasons for its inclusion, providing an option to disable it would accommodate those who prefer a different approach to styling in their projects. |
Is your feature request related to a problem?
At this moment, this is the way you can write global styles inside a component: Example
Why this isn't a good solution?
index.html
page)?document.body
with help of a component?.Describe the solution you'd like
Components styles need to be scoped by default, right? So we can just add
global
attribute to the style tag:Also, it most be possible to use 2 style tags:
I mean we need to be able to use 2 style tags, one scoped style for the component and one global style to apply anywhere we use the component.
Right now it's not possible to use 2 style tags. If anytime this feature was available, it needs to give an error if both style tags were the same and not give an error if one of them has the
global
attribute.How important is this feature to you?
Very important. It makes the Svelte be one step back from being able to fly to the moon 🌔.
Additional context
If you want this feature to become real, please like and share🌼 You don't need to write a commit just to say you agree, because then the issue page becomes less readable and we don't want this to happen. But I think if you have example use cases, it can be helpful to show the maintainers how much this feature is important.
The text was updated successfully, but these errors were encountered: