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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Changing the colour of...
Power Apps
Unanswered

Changing the colour of a button when clicked

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi

 

 

I've got a button which OnSelect sets a variable which I use later to die or show fields. How would I get the colour of the same button to change when it's clicked? Do I need to select a Property and what would I need to put in it? 

 

Thanks in advance.

Categories:
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Buttons have a PressedColor property you can edit. Does that answer your question or do you want the button to toggle colors when it's pressed?

    To toggle the button's color, put this formula wherever you see fit (Application's OnStart or Form's OnVisible)

     

    ClearCollect(ButtonColors,{Pressed:true,Color:RGBA(255, 0, 0, 1)},{Pressed:false,Color:RGBA(0, 255, 0, 1)});
    Set(ButtonPressed,false);

     

    Replace the color values with whatever colors you'd like.
    Then, on the button you want to toggle, put this formula in the OnSelect property somewhere

     

    Set(ButtonPressed,!ButtonPressed);

     

     Finally, on the button's Fill property, put this formula

     

    LookUp(ButtonColors,Pressed=ButtonPressed,Color)

     

     

  • ArniePrinceton Profile Picture
    4 on at

    Hi all-

    I did exactly as suggested by Eric, but the buttons are just black all the time. Probably a beginner's oversight on my part. Any ideas what to check? Thanks!

  • ArniePrinceton Profile Picture
    4 on at

    Well, it appears as though it worked once I logged out and back in. But now I have another problem.

    I have two buttons, but they both change colors as designed using the instructions above. How do I make only the clicked button change?

    Button 1 OnSelect action is: Set(ButtonPressed,!ButtonPressed);UpdateContext({FilterByNoticeNeeded:!FilterByNoticeNeeded})

    Button 2 OnSelect action is: Set(ButtonPressed,!ButtonPressed);UpdateContext({FilterByNoticeNeeded2:!FilterByNoticeNeeded2})

    I am so over my head, but I will learn it!
    2021-04-22_13-24-30.jpg

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 224 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 126

Last 30 days Overall leaderboard