A
A
Andrew2021-05-14 21:40:18
css
Andrew, 2021-05-14 21:40:18

How to apply styles from parent component to class passed to slot?

Let's say there is a component that has a slot.

<template lang="pug">
.my-component
    // some component data
    slot(name="hello")
</template>

<style lang="sass" scoped>
.hello
    // some styles
</style>


And I want the classes described inside this component to be applied to the blocks that are passed through the slot.

<template lang="pug">
.another-component
    MyComponent
        template(#hello)
            .hello Blah blah blah
</template>


In this case, it is clear that Vue defines classes as belonging to different scopes, but removing the scoped property is unwise to achieve my goal. Is there any other way? Other than duplicating the .hello class rules in every component where it will be used.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yuri, 2021-05-14
@AndrewRusinas

Everything is in the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question