Showing results for 
Search instead for 
Did you mean: 
Not applicable

How do you turn a button into a different colour when its pressed?



I've added a button, what I want it to do is simply toggle between true and false and have it change colour to indicate that when pressed.


How do you do that?


Accepted Solutions
Community Champion
Community Champion

Hi @JC75


Yup, looks like my understanding for English still needs more improvement.

(Maybe I always used to translate in my mind into Chinese when reading).


The best and most useful syntax used in PowerApps;

- UpdateContext

- x = x+1 (widely used in any programming languages for Looping purposes

- Switch (If is another alternative, but longer codes)


Here it is the final sample and hope this time I have understood your messages.


Loop, with unlimited Click; change as you wish!Loop, with unlimited Click; change as you wish!


Have a nice day.

Good nite.


View solution in original post

Community Champion
Community Champion



Each button has many variable for you to control:

- PressedFill

- PressedColor

You can make changes over the color as you wish.



Power Apps
Power Apps

If you want to change the color of the button while it's pressed, you can change the PressedColor (for the font color) and PressedFill (for the background color) of the button.


If you want to use the button as a toggle so that anytime it is pressed it will change the color of either the button itself or another control, you can use a context variable that is toggled in the OnSelect handler of the button. For example, if you want to use the button to toggle the color of itself and another control (say, a text box), you would use those formulas:

Button1.OnSelect: UpdateContext({ toggleValue: !toggleValue })
Button1.Color: If(toggleValue, Color.White, Color.Yellow)
Button1.Fill: If(toggleValue, Color.Blue, Color.Green)
TextBox1.Color: If(toggleValue, Color.Black, Color.White)
TextBox1.Fill: If(toggleValue, Color.White, Color.Black)
Regular Visitor

You can find the options mentioned by the other users by:

  • selecting the button
  • going to 'View'
  • click on 'Advanced'
  • in the advanced-section, click on the small arrow at the bottom of the section
Not applicable



It came up with an error, I copy and pasted it into the Action On Select part.

Thanks for you help everyone with this

Community Champion
Community Champion



You might have misunderstood Carlos.


1. Select the Button (which you wish to click), you can see OnSelect (Left Hand Side pane), and fill-in

UpdateContext({togglevalue: !togglevalue}) next to the box of fx.b

2. On the Left Pane again, look for Color & Fill and fill-in as:

Color (of the font inside the Button) next to fx: If(togglevalue, Color.White, Color. Yello})...or any color you wish

Fill... (fill of the Button) next to fx: If(togglevalue, Color.Green, Color.Red).....or any color you wish

TextBox1 (Color, Color, Border,...). as above

and any other.


You can change almost everything as long the you had accomplished No. 1: UpdateContext({togglevalue: !togglevalue}).



1. togglevalue is a Context Variable, you assign to the Button to toggle true and false when you click.

2. ! means reverse to the first value. If true, then false, if false, then true, and vice versa.

3. This Context Variable only works in the SAME SCREEN.

3. If(togglervalue,....) here togglevalue measn true


Hope this can clarify the whole scenario from Carlos.


Not applicable

Bugger, I realy don't know what I'm doing here. I think I made a mess of it :0(

Community Champion
Community Champion



I did more mistake than you and misunderstood of what they said initially.

If you are catching up faster than be before.

Keep it up....Will always share to learn together.

Have a beautiful Sunday.

(Listen to Bonnie M)

Advocate IV
Advocate IV

Ok how woud you expand this to cycle through say 3 colours? I have a round shape, that each time the user selects it, i want it to cycle through Green, Orange, Red.



Community Champion
Community Champion

Hi @JC75


You have to use:

- Timer

- Set the Circle.Fill = 

            If(Timer1_1.Value <= 1000, Color.Green, Timer1_1.Value > 1000 && Timer1_1.Value <= 2000, Color.Orange, Color.Red)


Then, set your own Duration, Repeat, Autostart, ....

Example: Circle.OnSelect = UpdateContext({clickme1: !clickme1})

where clickme1 is the variable for Timer1_1

- Timer1_1.Start = clickme1.


Anyway, it is up to you to design.


Click on circle, and startClick on circle, and start


Hope this helps.



Helpful resources

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.


New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (4,288)