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 / How to change backgrou...
Power Apps
Answered

How to change background color of button when it has been selected?

(0) ShareShare
ReportReport
Posted on by 341

I would like to change the background color of a button to grey when it has been selected. what is the proper formula?

Categories:
I have the same question (0)
  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Evan_S1 In the OnSelect of the Button set a variable,

                UpdateContext({varBackground: Color.Blue})

    Set this variable to the Fill property of the Button   

     

    Please remember to give a 👍 and accept my solution as it will help others in the future.

  • Evan_S1 Profile Picture
    341 on at

    It looks blue when selected however it doesn't stay that color.

     

    I would like it to stay the color grey when selected and then change back to its normal blue color when depressed.

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Evan_S1 just change the Pressed Color property.

     

    Please remember to give a 👍 and accept my solution as it will help others in the future.

  • Evan_S1 Profile Picture
    341 on at

    I did, however it shows an error. 

    Evan_S1_0-1681476460104.png

     

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Evan_S1 set the PressedColor property of the Button to the desired color, e.g. Color.Gray

  • Evan_S1 Profile Picture
    341 on at

    The button does not stay gray. I want it to stay gray when it is selected, then turn back to its original color when pressed again.

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Evan_S1 Set a variable in the OnSelect of the Button,

    Set(btnSelected,!btnSelected)

    Set the Fill property to, 

    If(btnSelected, Color.Gray, Color. Blue) 

    Please remember to give a 👍 and accept my solution as it will help others in the future.

     

  • Evan_S1 Profile Picture
    341 on at

    It kind of works now in reverse of what I wanted. The button turn blue when selected and gray when unselected. Would prefer it to be opposite. 

    Also, I have other buttons that I want to format the same way, although when I use the same function on other buttons. All the buttons turn the same color when only one of them is selected. 

  • CNT Profile Picture
    10,921 Super User 2024 Season 1 on at

    @Evan_S1 Just reverse the colors

    If(btnSelected, Color.Blue, Color. Gray)

     

    other buttons.... Each button will need a different variable

     

    Please remember to give a 👍 and accept my solution as it will help others in the future.

  • Evan_S1 Profile Picture
    341 on at

    @CNT What different variable would I use?

    All Buttons currently have this as the code.

    UpdateContext({btnChoice:If(btnChoice=Self,Blank(),Self)});Set(btnSelected,!btnSelected)

     

     

    My Buttons names are:

    Vertical

    Modified

    Horizontal

     

     

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 534

#2
WarrenBelz Profile Picture

WarrenBelz 416 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 306

Last 30 days Overall leaderboard