0

I have some problems implementing props in style tag. I have props like:

 props: {
    icon: {
      type: String,
      required: true
    },
    label: {
      type: String,
      required: true
    }
  }

And I want to use label props in Style, like:

    <style scoped lang="scss">
      .class{
        color: label;
      }
    </style>

is that possible? Because it's not working like this

Idea is actually to make a call like:

.drop-color{
    color: map-get($var, label);
  }

This will work if I define it as;

.drop-color{
    color: map-get($var, 'blue');
  }

I just need to pass prop label instead.

Rade Iliev
  • 127
  • 1
  • 8

1 Answers1

0

With new script setup you're able to do it using v-bind of vue 3.2.x:

<script setup>
import {defineProps} from 'vue'

const props = defineProps({
     icon: {
      type: String,
      required: true
    },
    label: {
      type: String,
      required: true
    }
})


</script>
  <style scoped lang="scss">
      .class{
        color: v-bind(label);
      }
    </style>

LIVE DEMO

Boussadjra Brahim
  • 64,851
  • 14
  • 107
  • 134