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.

Scoped style and slotted elements

See original GitHub issue

I have questions about <style scoped>, <slot> and ::slotted pseudo-element selectors.

  • Does not Vue.js support CSS scoping spec?
  • If so, does Vue.js have a plan to support CSS scoping spec?

For example to explain: gist@de98f89c48e16dea2230d13925d3b3e2.

I expected a blue box to exist inside of a red box because the CSS rule slot::slotted { } should apply to distributed elements. But actually, a red box existed inside of another red box bacause CSS rule div { } applied to distributed elements wrongly and slot::slotted { } was merely ignored.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Reactions:4
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
Crazymax11commented, Feb 28, 2018

@yyx990803 as mentioned @caikan styles will conflict if scoped parent and scoped child will have same selector in their styles and this selector will be used in slot content. I think slotted content should be affected only by scoped parent styles, except slot root.

It’s very confusing behavior.

For example we use scoped styles and this allow us to use simpler classnames. For example .submit-button instead of my-component-name__submit-button

But if I make component with .submit-button and slot, and then some parent will place .submit-button in slot too, .submit-button styles will be broken. Current behavior breaks isolation between parent-child - parent should not know about classnames of child, but for now I should check is child component have same classname or not.

reproduce link

6reactions
jwahdatehaghcommented, Jul 27, 2017

This doesn’t work for me on either named or unnamed slots content. Only the parent component id is attached to the slot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

slotted() - CSS: Cascading Style Sheets - MDN Web Docs
The ::slotted() CSS pseudo-element represents any element that has been placed into a slot inside an HTML template (see Using templates and ...
Read more >
Vue scoped styling not working with elements that have ...
Moving my styling to a locale setup but seeing that when I insert element into slot containers they will not work.
Read more >
SFC CSS Features
When a <style> tag has the scoped attribute, its CSS will apply to elements of the current component only. This is similar to...
Read more >
Styles
Styles scoped to an element's shadow tree don't affect the main document or ... Outside style targetting a slotted child can override ::slotted()...
Read more >
Vue Tip: Special CSS Selectors
Slotted Selectors. By default, scoped styles do not affect contents rendered by <slot/> but we can use the :slotted pseudo-selector to apply styles...
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