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 button color ...
Power Apps
Unanswered

changing button color after being pressed

(0) ShareShare
ReportReport
Posted on by 152
I have 4 buttons that I am using to filter out a gallery. the filter is working, i used a variable depending on what the user clicks on.
 
I am trying to change the color once it has been pressed down, and can't seem to get that to work. 
Do I changed the Fill with a variable depending if it was pressed?
If another was pressed, how do I change the color? do if, else variable?
 
Keeping it simple, it's default blue, want to change it to Green.
Categories:
I have the same question (0)
  • RobElliott Profile Picture
    10,428 Super User 2026 Season 1 on at
    Set your OnVisible property for the screen and  the App OnStart property to 
    Set(varSelected,Color.Blue).
     
    Add a button to your app. Set the OnSelect property to 
    Set(varSelected, Color.Green)
     
    and the Fill property to varSelected.
     
    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User.
    Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)
  • nerdyplayer Profile Picture
    152 on at
    Thx Rob, it did change the color, but i have 4 buttons to work as the filter. If a user selects one of the others, i want the color to change back.
     
    Right now, if i click on one, all the others will change color too and cannot revert back.
  • Ytalo Silva Profile Picture
    193 Moderator on at

    Hello, in cases like this, I usually use a gallery of buttons. Basically, I create a collection in this format:

    ClearCollection(
    colMenuButtons,
    {label: "Button1", action: "", defaultColor: ColorValue("myColorHex"), selectedColor: ColorValue("myColorHex")},
    {label: "Button2", action: "", defaultColor: ColorValue("myColorHex"), selectedColor: ColorValue("myColorHex")},
    {label: "Button3", action: "", defaultColor: ColorValue("myColorHex"), selectedColor: ColorValue("myColorHex")}
    )

    This can be done in the OnStart of the application. Then, I create a gallery and add a button. In the Items property of the gallery, I set colMenuButtons. In the button’s label, I use ThisItem.Label, and for the Fill property, I set:

    If(ThisItem.isSelected, ThisItem.selectedColor, ThisItem.defaultColor)

    This way, I can change the color of the selected item.

    To define the actions for each button, in the OnSelect property of the button, I use a Switch statement.

    This is just one way to do it. Another way would be to create 4 color-specific variables for each button. In the Fill property of each button, you would use:

    If(varButton1 = true And Or(varButton2,varButton3,varButton4) = false,ColorValue("colorSelectedHex"), ColorValue("colorDefaultHex"))

    Make sure to reset the variables for the other buttons when one is selected.

    I hope this helps!

  • CU05010146-0 Profile Picture
    14 on at
    I have used the following when creating different buttons within an app recently.  I set the OnSelect and Fill properties as below:
     
    For Button1:
    OnSelect property setting:
    Set(SelectedButton, "Button1")
     
    Fill property:
    If(SelectedButton = "Button1", Green, Blue)
     
    For Button2:
    OnSelect property setting:
    Set(SelectedButton, "Button2")
     
    Fill property:
    If(SelectedButton = "Button2", Green, Blue)
     
    Substitute the name of your buttons for "Button1," Button2," etc. 
     
  • WarrenBelz Profile Picture
    154,799 Most Valuable Professional on at
    I posted before I noticed that @RobElliott's post at the bottom is the direction I would take - I might as well continue, but please mark Rob's as the solution. You simply need multiple Variables and you can use UpdateContext
    UpdateContext(
       {
          varColor1: Color.Blue,
          varColor2: Color.Blue
    varColor3: Color.Blue
    varColor4: Color.Blue } )

    then change whichever you need.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 538

#2
WarrenBelz Profile Picture

WarrenBelz 420 Most Valuable Professional

#3
Haque Profile Picture

Haque 305

Last 30 days Overall leaderboard