Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to change a button's text colour programmatically?

Hi, sorry if this has been previously answered but I'm struggling to figure it out. I have a button like this:

<use id="b1" class="button" href="#push-button" y='40' height="65"
            fill="fb-black" font-family="System-Regular" font-size="20">
          <set href="#text" attributeName="fill" to="fb-peach" />
          <set href="#text" attributeName="y" to="12" />
          <set href="#text" attributeName="text-length" to="20" />
</use>

How do I go about changing the colour of the text inside the button programmatically? I don't understand how to access the attributes that are inside the set tags. Sorry if this is a stupid question or something that I don't understand about how this works, but I would appreciate an answer. Thank you!

Best Answer
0 Votes
1 REPLY 1

I am not certain that this would work, but if you added the text to a class, then you could easily overload the color for that class.  Here is an example I use for my watchface.

 

<text id ="monthLabel"class="face"></text>

 

My CSS file has this in it...

.face {fill:#20e7ff }

Then, in my css, I define the style attributes for the class face.  I think you can overload that too, changing it programatically in your code.

 

Edit: I added the CSS too just in case it helps anyone.

Best Answer
0 Votes