I want to use predefined variables in my Vue 3 component.
<template> <div class="rounded img-container"> <span v-if="!props.ready">Du musst noch ein Bild aufnehmen!</span> </div> </template> <script lang="ts" setup> import { defineProps } from "vue"; const props = defineProps({ ready: { type: Boolean, required: true } }) </script> <style lang="scss" scoped> .img-container { aspect-ratio: 3 / 2; margin-left: auto; margin-right: auto; background: $red; <- Error } .text-small { font-size: 2em; } </style>
Unfortunately, I get the error "SassError: Undefined variable.". What do I have to import to use Vuetify's global variables?
The use of these colors is not so straightforward.
Recorded herehttps://vuetifyjs.com/en/function/sass-variables/#webpack-install Note
Requires sass-loader@^7.0.0
and change webpack configurationYou can also skip this if you import color variables in the component file (the number of
../
may vary)The next thing to remember is the structure of the object
Here is an excerpt
So colors don't map to strings, but to objects (see
map-deep-merge
), so you can't use$red
to give you the color value.Instead, you can use the
map-deep-get
function to get the base redSo it looks like this