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 / Change button backgrou...
Power Apps
Answered

Change button background color on click (No Fill property)

(1) ShareShare
ReportReport
Posted on by 59

Ok. What I'm trying to do is pretty simple. I have a screen with multiple buttons. All I want to do is when a user clicks on a button, it changes the background color (to indicate it's selected). So for instance, the button is set to Primary in the Style & Theme area. Looking at other documentation, it seems like I should be able to set the Fill property of the button with a simple Update Context True/False statement in the OnSelect property.

 

When I look at the properties for the button, there is no Fill property.  The closest I see is Appearance or BasePaletteColor.  What am I missing? New to PowerApps but this seems like it should be a fairly easy thing to do. Any help would be appreciated.

Categories:
I have the same question (0)
  • Verified answer
    Ami K Profile Picture
    15,679 Super User 2024 Season 1 on at

    @gbach2290 - because modern controls remain in preview, they are not as fully featured as Classic controls. If you add the classic Button control into your app, you will see the Fill property.

  • gbach2290 Profile Picture
    59 on at

    Well, I'll be.... didn't know there was a difference. I can see now. Thanks so much.  BTW I did manage to figure out my issue with the modern button.  Now I'll just have to see if I want to switch out my modern buttons for classic buttons. 

  • Verified answer
    Ami K Profile Picture
    15,679 Super User 2024 Season 1 on at

    @gbach2290 - unless a modern control contains a feature/allows the user to do something which a classic control cannot replicate, I would stick to deploying an app with classic controls into your production environment as they are robust and not prone to the possible defects inherent with preview controls.

  • gbach2290 Profile Picture
    59 on at

    Makes total sense. Thank you for your help!

  • Kelvirino Profile Picture
    16 on at
    So, gbach2290 - how do you/did you make it work with modern controls (since I don't have Admin access on our company's account)?   I'm having the same issue as you originally described.
  • gbach2290 Profile Picture
    59 on at
    @Kelvirino, here's what I did:
    • Select the button
    • In the OnSelect property, I used Update Context. 
      EXAMPLE:  UpdateContext({selectK1121_S1_SystemChecked_btn: !selectK1121_S1_SystemChecked_btn})
    • In the Fill property, I used the variable to determine the fill color.
      EXAMPLE:  If(selectK1121_S1_SystemChecked_btn,RGBA(0,200,0,1),RGBA(127,127,127,1))
       
  • Kelvirino Profile Picture
    16 on at
    @gbach2290 - Thank you!
  • Suggested answer
    CarlosFigueira Profile Picture
    on at
    On modern buttons you can use the 'BasePaletteColor' property to define their background (fill) color. If that property is set to blank, then it would use the color of the app theme.
     
    In the example below, I'm using a collection to store the state of the buttons, and if the value relative to the button is 'Pressed', the BasePaletteColor property is updated to a green color (otherwise it is left blank, which uses the app theme):
     
    The property values for the buttons:
    BasePaletteColor:
      If(LookUp(colButtonStates, Name = Self.Text, State) = "Pressed", RGBA(146, 200, 0, 1))
    OnSelect: 
      With(
        {currentState:LookUp(colButtonStates, Name = Self.Text)},
        If(
          IsBlank(currentState),
          Collect(colButtonStates, { Name: Self.Text, State: "Pressed" }),
          Patch(
            colButtonStates,
            currentState,
            { State: If(currentState.State = "Pressed", "Not pressed", "Pressed") })))
    Hope this helps!

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 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard