Skip to main content
Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Suggested answer

When the "star" is clicked - make it yellow

(1) ShareShare
ReportReport
Posted on by 44

Hello,

In my Power App, there is a "Star" icon (which doesn't have all the events like other icons). When I click on the Star, it should turn gold (the function is already provided - clicking adds the selected item to the Favorites list for the current user). Also, the user must be able to remove the selected item from the Favorites list by clicking on the "X," and the star should return to its colorless state. Thank you for your help! 

  • Suggested answer
    Nandit Profile Picture
    1,563 Super User 2025 Season 1 on at
    When the "star" is clicked - make it yellow
    Hi @stayclassy
     
    I have been able to do this by creating two collections "Documents" and "User Favorites". Please see below. 

    Documents
    ClearCollect(
        Documents,
        {
            Doc: "Doc1.docx",
            ID: 1
        },
        {
            Doc: "Doc2.docx",
            ID: 2
        },
        {
            Doc: "Doc3.docx",
            ID: 3
        },
        {
            Doc: "Doc4.docx",
            ID: 4
        }
    );
     
    User Favorites (Replace placeholder email addresses)
    ClearCollect(
        User_Favorites,
        {
            Email: "----E-Mail Address---",
            Favorites: "1,2"
        },
        {
            Email: "----E-Mail Address---",
            Favorites: "3,2"
        },
        {
            Email: "----E-Mail Address---",
            Favorites: "1,3"
        },
        {
            Email: "----E-Mail Address---",
            Favorites: "4,2"
        }
    );
    
    Documents Gallery
    Gallery Items: Documents (Collection)
     
    Star Icon Fill
    If(
        ThisItem.ID in Split(
            LookUp(
                User_Favorites,
                Email = User().Email
            ).Favorites,
            ","
        ),
        Color.Gold,
        Color.White
    )
    Star Icon OnSelect (If user does not exist in collection, patch new record otherwise update the existing record)
    Patch(
        User_Favorites,
        If(
            IsBlank(
                LookUp(
                    User_Favorites,
                    Email = User().Email
                )
            ),
            Defaults(User_Favorites),
            LookUp(
                User_Favorites,
                Email = User().Email
            )
        ),
        {
            Favorites: If(
                ThisItem.ID in Split(
                    LookUp(
                        User_Favorites,
                        Email = User().Email
                    ).Favorites,
                    ","
                ),
                Concat(
                    Filter(
                        Gallery1.AllItems,
                        Star1.Fill = Color.Gold && !(ID = ThisItem.ID)
                    ),
                    ID,
                    ","
                ),
                Concatenate(
                    Concat(
                        Filter(
                            Gallery1.AllItems,
                            Star1.Fill = Color.Gold && !(ID = ThisItem.ID)
                        ),
                        ID,
                        ","
                    ),
                    ",",
                    ThisItem.ID
                )
            )
        }
    );
     
    User Favorites Label (Just to see the favorites of current user)
    LookUp(User_Favorites, Email = User().Email).Favorites
     
     
    If this answers your query, please mark this response as the answer.
    If this was helpful. please leave a like. Thanks!
     
     
  • Suggested answer
    Michael E. Gernaey Profile Picture
    44,451 Super User 2025 Season 1 on at
    When the "star" is clicked - make it yellow
    HI,
     
    You have posted in the Pro Dev & ISV so the expectation is your are a pro and stuck on something.
     
    I am not sure if you are using a Canvas App or Model driven. You have provided no details at all about names of controls, or pictures of your app.
     
    Are you trying to ask for help with the help or building a PACF Component? I am not sure at all.
     
    Also, you should have an app with basic functionality and please post this in the Power Apps, Building Apps Section
  • Suggested answer
    WarrenBelz Profile Picture
    148,743 Most Valuable Professional on at
    When the "star" is clicked - make it yellow
    Hi  stayclassy,
    You need a field in your Data Source (I will call it Favourite here) - Text is easiest, Then OnSelect of the Star icon (this allows unselecting as you have specified)
    Patch(
       DataSource,
       ThisItem,
       {
          Favourite:
          If(
             ThisItem.Favourite = "Yes",
             "No",
             "Yes"
          )
       }
    )
    Then the Fill of the Icon (I am assuming it is currently White)
    If(
       ThisItem.Favourite = "Yes",
       Color.Yellow,
       Color.White
    )
     
    Please click Does this answer your question if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1