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 / Make a component with ...
Power Apps
Answered

Make a component with dynamic width

(0) ShareShare
ReportReport
Posted on by 102

Hi all,

I have an app with a lot of elements that I want to give a specific look, including a background that is a shape of a  specific colour, border thickness etc., but rather than have to change dozens of these shapes when editing I would like to make a component.

However, I want the shape to have a relative width: e.g., Parent.Width - 20 

When making the component I have to put a shape into the screen, and I can then give the shape this relative width, but the component itself has a static width that won't accept a formula as its value.

Is there a way round this?

Categories:
I have the same question (0)
  • iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    Think of the component more like an aspect ratio - it is X wide by Y high, you can then scale this in your app - there are ways to do truly responsive components but they are quite heavily involved.

    If you keep the thought of an aspect ration, the size of the component inside the component doesn't matter as you can make the size of the component dynamic when inserted into the App as a control. When you insert the component, make the component's width relative/dynamic from the App side not the component side if its something like headers/ backgrounds/ panels.

     

    I have some stuff you could look at in my Branding Template that might be of use to you - will also save you editing colours etc across the App before you even look at the component aspect 🙂

  • Matt_uhb Profile Picture
    102 on at

    @iAm_ManCat ,

    Thanks for your reply - that does help to understand how the components work.

    Unfortunately, I want my shapes to be a specific, static height, but shrink the width (only) relative to the size of the parent, so I actually want the aspect ratio to change, where necessary.

  • Verified answer
    iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    If you make your component background transparent, the visual relative width will show in your App without the white background.

    Then, instead of referring to parent, use the component name like

    WidthThinger.Width * 80%

     

    I have examples of this in the template with regard to the header.

     

    also here:

    RelativeComponent2.gif

     

    I've attached a quick POC app if that helps,

     

    Cheers,

    Sancho

  • Matt_uhb Profile Picture
    102 on at

    It doesn't quite work for me in this instance, as I need it to be left-aligned to the parent and not centred, and if I align it that way it just resizes the whole item.

    However, your solution is simple and clever, and has helped me with another idea I had, so I've marked it as solved.

    Thanks for your help.

  • iAm_ManCat Profile Picture
    18,228 Most Valuable Professional on at

    Awesome, glad it helped you get to where you needed!

    Hope you have a good weekend,

    Cheers,

    Sancho

  • Matt_uhb Profile Picture
    102 on at

    Thanks Sancho, you too.

    Kind regards

     

    Matt

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard