I need to pass class name from script to style
<script
lang="ts"
setup
>
const className = ref('some-class')
</script>
<style
lang="sass"
module
>
.#{v-bind(className)}--dynamic
pointer-events: none
</style>
In this case I get an error:
Error: expected selector.
.v-bind(className)–dynamic ━ error in interpolated output
UPD: To clarify, I use this component in various others and I need the class to be with a prefix that I pass from the parent component
2
Answers
@Ilya Degtyarenko
You can specify your classes in the styles and use it like this:
Under the hood, the
v-bind
in style creates a CSS variable that can be updated in style attribute of the element and used as value in the CSS rule :and
and it’s not possible to use CSS var as class name.