Skip to content

Using useCssModule return value in <style module> #7732

Discussion options

You must be logged in to vote

Thanks to @skirtles-code and their answers on Discord, I have found the solution

There was a slightly different syntax that I've missed on docs. we need to wrap property path with quotes as mentioned in here https://vuejs.org/api/sfc-css-features.html#v-bind-in-css

.item {
    grid-area: v-bind('modules.item');
    // or
    // grid-area: v-bind('$style.item'); // works as the same
}

And the final version is

<template>
    <div :class="$style.grid">
        <div :class="$style.item"></div>
    </div>
</template>

<style module lang="scss">
.grid {
    display: grid;
}

.item {
   grid-area: v-bind('$style.item');
}
</style>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by seahindeniz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant