alex-oleshkevich / vue-tabler-icons

Fully customizable free SVG icons made as Vue components.
MIT License
150 stars 13 forks source link

how can i set dynamic icons? #3

Closed apithy-isidro-martinez closed 3 years ago

apithy-isidro-martinez commented 3 years ago

What is the best way to set the icon name dynamically based on a variable? I tried this way and it works, but I don't know if there's a better way to do it.

<component :is="status ? chevron-right-icon':'chevron-left-icon'" />

<script>
export default {
  data () {
    return {
      status: true
    }
  }
}
</script>

If this way is correct, you may update the readme with this info

alex-oleshkevich commented 3 years ago

Yes, this is totally fine. You also can wrap components into multiple <template> tags but it is more verbose:

<template v-if="status">
    <chevron-right-icon />
</template>
<template v-else>
    <chevron-left-icon />
</template>