I have this sample code:
<template>
<custom-button>
#shadow-root (open)
<a href="#"></a>
<other-custom></other-custom>
</custom-button>
</template>
<style scoped lang="scss">
custom-button{
:deep(a) {
outline:1px red solid;
}
}
</style>
But the style does not apply. I tried with scoped and slotted but no results. How can apply a style to the anchor? Thank you.
NEW SAMPLE
test.vue
<template>
<custom-button>
</custom-button>
</template>
<style scoped lang="scss">
.custom-button {
:deep(a) {
outline: 3px red solid;
}
}
</style>
custom-button.vue
<template>
<a href="#">Link</a>
</template>
<script>
export default {
name: 'custom-button',
};
</script>
This does not work using Tolbxela demo.
UPDATE
Yes, it does not work for the second sample. I am not really sure why, but I suppose, that the scoped CSS will be applied only at the App level.
But why not do it simpler and just put the style directly into the
custom-button.vue?It does work well this way. Here is the updated Codesandbox
Or you can do something like this
At first, there should be one curly bracket more in the style.
Then, if you omit all custom elements, the code works as intended.
Here is the Codesandbox