Closed
Description
This issue relates to #901, which was closed in favor of sveltejs/rfcs#13, which does not address multiple problems mentioned in 901.
Problem statement
It is currently not possible in Svelte for styles within a component to impact areas outside of the component.
This impacts, among other things:
- The ability for nested components to have styles related to the nesting.
- The ability to have component styles be related to placement, ie if both components are on the page, style them differently.
- The ability for stylesheets to easily impact groupings of components (ie this is my "navigation" stylesheet).
- The ability to DRY style (I can't reuse certain styles because components can't impact eachother).
- The ability to opt-in or opt-out of style encapsulation at any given time.
- The ability to use the first letter in the CSS acronym, the cascade.
- The ability to insert svelte into a legacy application with preexisting CSS.
Examples of how other frameworks work around this problem
- Angular: https://blog.angular-university.io/angular-host-context/ or manually defined scopes https://docs.angularjs.org/guide/scope
- Vue: https://bambielli.com/til/2018-08-19-how-to-target-child-components-with-scoped-css-in-vue/
- React: Style components, stylable modules, CSS modules... https://github.com/css-modules/css-modules or https://blog.bitsrc.io/5-ways-to-style-react-components-in-2019-30f1ccc2b5b
Metadata
Metadata
Assignees
Labels
No labels