Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

Svelte: styling the child component from parent component without using :global

$
0
0

In a parent component I am passing down a CSS class to child component.

Parent.svelte

import Child from .Child<div class="parent-component-class">  <Child childClass="child-component-class"></div>

Child.svelte

export let childClass;<div class={childClass}></div>

I want to be able to style the child-component-class in the <style> tag of a parent component. The only way I found how to do it is using a "global" prefix:

<style lang="scss">:global(.child-component-class) {  /* some styles */}</style>

But that is not what I want. I want the styling to stay scoped inside the component Parent and down to it's child components. Any suggestions?


Viewing all articles
Browse latest Browse all 1541

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>