Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
How to let color of svg and span text color same

Here is my Vue code:

      <icon
          :color="itemDynamicColor"
          :data="icon"
      />
      <span v-bind:style="dynamicStyle">SpanText</span>

I want the icon and span text keep same color, as you see, I use computed property to define icon color and span color. However I think this way is a little stupid.

I wonder if there is any better way?

EDIT

Actually the color of both will change when some data change.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You could handle this all in plain CSS by using a custom property for the color you want, and then setting the color of the <icon> and <span> to that.

about 4 years ago · Juan Pablo Isaza Report

0

The color of both will change when some data change.

To achieve this, you can update the dynamicStyle object in both <icon> and <span> based on the condition as per your requirement.

Demo :

new Vue({
  el: '#app',
  data: {
    dynamicColor: {
      color: 'red'
    }
  }
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<div id="app">
  <!-- For icon you can apply same dynamicColor property dynamically -->
  <span :style="dynamicColor">SpanText</span>
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!