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 / Components - Custom pr...
Power Apps
Answered

Components - Custom property as a dropdown

(0) ShareShare
ReportReport
Posted on by 13

Greetings,

 

I am trying to find a way to present a custom property of a Component as a dropdown of choices.  For example, a custom property call Background Color with only the choices Red, Blue, Green presented in a dropdown.

 

Cheers

Categories:
  • Kirkby Profile Picture
    659 Moderator on at

    Hi. @Noral 

    If the purpose is to establish design guidelines by deploying a common component that restricts elements, such as background color. I would include tips that appear when an invalid color is chosen.    

     

    confidential_11.png

    Add tips that explains when invalid color is configured

    confidential_11 (3).png

    Show tips only when the color is invalid, ensuring the screen remains unobstructed.

    confidential_11 (2).png

    when a valid color is configured  and  an invalid color is configured

    confidential_11 (4).png

    My understanding is that there is no feature that blocks selection of invalid option in advance, so I used the above approach. I understand that this might be troublesome for the component developer, but to some extent, it could be user-friendly and intuitive when the common component is utilized.

    I hope this helps.

     

    If you found my answer helpful, I'd appreciate it if you could mark it as 'Accept as solution' or give it a thumbs up.

  • Noral Profile Picture
    13 on at

    Thank you @Kirkby for your information.

     

    This is a good solution if I wanted the developer to have a dropdown selection of valid colors, but this is not what I am looking for.

     

    To use your example, I would like the colors in the dropdown and on the properties pane of the component that would be consumed by the component, not in the app.

     

    Any suggestions?

    Cheers

  • Chris-D Profile Picture
    1,246 on at

    Hi @Noral,

     

    I have actually rebuild the dropdown as a component to extend it's functionality. 

     

    In my component, I have a property: Options, type input, table, which are the options for my dropdown. You could add your colour to this, in this format:

     

    [
     { ID: 1, Title: "Red", Colour: Color.Red},
     { ID: 2, Title: "Green", Colour: Color.Green},
     { ID: 3, Title: "Blue", Colour: Color.Blue},
    ]

     

     
    Your Dropdown.Items then points to this property, with the Value then selected as Title. That should give you a dropdown with the options Red, Green, Blue. 

     

    Then, in your Dropdown.OnChange, set a variable to the selected option:

     

    Set( _Selected, Self.Selected);

     

     
    Finally, create an output property: Selected, output, record, which will give your component an output record which will be the selected input record. Set its value to:

     

    Coalesce( _Selected, First( Self.Options))

     

     

    Use Coalesce() here to default the output to the first option specified in case _Selected is still blank, which it will be until the dropdown has been changed.

    You can then access the selected colour with:

    Component.Selected.Colour
  • Chris-D Profile Picture
    1,246 on at

    EDIT: I think I misunderstood your question. I think you want this without the input property? In this case, instead of defining the option list in the input property of the component, use that code directly on the Dropdown.Items. It should still work the same way and output the colour record. 

    If you want to output the colour directly, and not the dropdown's option record, change the component output to type of Color, and the Dropdown.OnChange to

    Set( _Selected, Self.Selected.Colour)

     

    That should work. 

  • Noral Profile Picture
    13 on at

    Thank you @Chris-D for spending time to help me on this.

     

    I believe a picture will clear things up, see the mockup below.  What I want to accomplish is for the component to only accept values from the dropdown of the property (I do not know if this is possible or how to do this).  These values would be defined in the Custom Component.

     

    Hopefully this clears things up 😊

     

    CustomComponentExample.png

  • Verified answer
    Kirkby Profile Picture
    659 Moderator on at

    Hi. @Noral 

    Unfortunately, Power Apps does not currently provide the feature that you want. Type of parameter should be defined with a text format as of now when making a component, even if it is an object like Color. That is why I suggested the approach. 

    It seems that you want the feature to make a component to be used easier from citizen developer perspective, and the feature will be available sometime. However, I think the priority will not be that high because Microsoft assumes that a user of a component has some knowledge about writing a program.

  • Chris-D Profile Picture
    1,246 on at

    Hi @Noral thanks for the picture. 

     

    I made a working example for you, based on my existing dropdown component.

     

    Here's a component and a rectangle:

    ChrisD_0-1698136611752.png

     

    When no colour is selected, the fill is transparent. Select a colour et viola! I think this is what you wanted? 

     

    ChrisD_3-1698136750322.png

     

    My component:

    Options: input, table:

    ChrisD_4-1698136844963.png

     

    SelectedOption: output, record

    ChrisD_5-1698136915064.png


    I use Coalesce() here to output a transparent colour if there's no option selected. I have some other code that adds the 'Select...' option at the top so it's possible that nothing is selected, but without this SelectedOption() must be one of your input records. 

    The rectangle's fill property is set to the output property of the component:

    ChrisD_6-1698137073272.png


    Hope this is helpful? 

  • Noral Profile Picture
    13 on at

    @Chris-D - I am sorry but this is not what I am wanting.  The dropdown I am asking about would be specifically on the Component Properties, yours is visible on the actual component.

     

    @Kirkby - Thank you for the information, I was afraid this was the case.

  • Chris-D Profile Picture
    1,246 on at

    Ah I see, sorry I misunderstood.

     

    The closest you could get would be an input type colour, but then validate it wherever you use it. You could have a text label that, if the colour is invalid, fills the component area, effectively hiding it, with an error message. 

    Or depending on what the colour is used for, use some on/off switches to determine the state of whatever it is. 

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 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard