web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Changing Button Colour...
Power Apps
Answered

Changing Button Colours As They are Clicked On

(1) ShareShare
ReportReport
Posted on by 10
New to Power Apps and looking to make a button change colour by clicking it. I need it to go from gray, to red, to yellow, to green, and then back to gray again. I have been trying other solutions in other posts, but can't seem to find anything that works for this particular situation. Would really appreciate help on this one - thanks in advance!
Categories:
I have the same question (0)
  • mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at
    hey
     
     
    try this:
     
    onvisible of screen for example:
    Set(btnColorState, 0)
    
    onselect of button:
    Set(btnColorState, 
        If(btnColorState = 3, 0, btnColorState + 1)
    )
    
    and then the fill property of the button:
    Switch(
        btnColorState,
        0, Color.Gray,
        1, Color.Red,
        2, Color.Yellow,
        3, Color.Green
    )
    

    you maybe need to set the hoverfill property of the button also to the same:
    Switch(
        btnColorState,
        0, Color.Gray,
        1, Color.Red,
        2, Color.Yellow,
        3, Color.Green
    )
    
    or you use other colors for it so the user knows hes hovering the button


    just tested and it worked
     
     
    if it helped please mark as verified answer
     
     
    cheers
  • AW-14112300-0 Profile Picture
    10 on at
    @mmbr1606 Thanks so much for your speedy response - will the formula you provided below also help ensure that several buttons on the same screen will change colours when clicking on them independently from one another? 
     
    For example, when I click on Button 1 and it changes colour, Button 2 remains the original colour as if it was not clicked on and then will only change colour itself when it is clicked on?
     
    Thanks so much!
  • timl Profile Picture
    36,393 Super User 2025 Season 2 on at
    To make this work independently for different buttons, you would need to use different variable names.
     
    Let's assume that you implemented mmbr1606's solution for Button 1. 
     
    For button 2, you would then add this to the OnVisible property screen and carry out the exact remaining steps, except that you would replace each instance of btnColorState with btnColorState2. 
     
    Set(btnColorState2, 0)
    
     
  • Verified answer
    mmbr1606 Profile Picture
    14,605 Super User 2025 Season 2 on at
    if u need a second one
     
    Set(btnColorState1, 0);
    Set(btnColorState2, 0)
    
    button one onselect:
    Set(btnColorState1, If(btnColorState1 = 3, 0, btnColorState1 + 1))
    
     
    button 2 onselect:
    Set(btnColorState2, If(btnColorState2 = 3, 0, btnColorState2 + 1))
    
    button 1 fill:
    Switch(
        btnColorState1,
        0, Color.Gray,
        1, Color.Red,
        2, Color.Yellow,
        3, Color.Green
    )
    
    button2 fill:
    Switch(
        btnColorState2,
        0, Color.Gray,
        1, Color.Red,
        2, Color.Yellow,
        3, Color.Green
    )
    
    if you would need a 3rd or 4th just use the same logic wit 3 and 4
     
    if that helped please mark as verified

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard