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 set style for t...
Power Apps
Answered

How to set style for the label of custom control?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello,
How can i set the new style for the label of custom control? Something like color, font family, etc...

 

Thanks,

I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    That's pretty straight forward.  You'll need to make a reference to a CSS file within your manifest (uncomment the css resources line below):

     

    <?xml version="1.0" encoding="utf-8" ?>
    <manifest>
     <control namespace="ControlsAndrewLy" constructor="TestProject1" version="0.0.1" display-name-key="TestProject1_Display_Key" description-key="TestProject1_Desc_Key" control-type="standard">
     <!-- property node identifies a specific, configurable piece of data that the control expects from CDS -->
     <property name="sampleProperty" display-name-key="Property_Display_Key" description-key="Property_Desc_Key" of-type="SingleLine.Text" usage="bound" required="true" />
     <!-- 
     Property node's of-type attribute can be of-type-group attribute. 
     Example:
     <type-group name="numbers">
     <type>Whole.None</type>
     <type>Currency</type>
     <type>FP</type>
     <type>Decimal</type>
     </type-group>
     <property name="sampleProperty" display-name-key="Property_Display_Key" description-key="Property_Desc_Key" of-type-group="numbers" usage="bound" required="true" />
     -->
     <resources>
     <code path="index.ts" order="1"/>
     <!-- UNCOMMENT TO ADD MORE RESOURCES
      <css path="css/TestProject1.css" order="1" />
     <resx path="strings/TestProject1.1033.resx" version="1.0.0" />
     -->
     </resources>
     </control>
    </manifest>

    Then, create the css folder with css file.

     

    Each control you create (with project.ts file), will need a class name.  E.g. Label has class name of YourLabelClass.

     

    Check out some of my projects for examples:

     

    https://github.com/365lyf/PCFControls

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks for your suggestion, but i mean the following label.

    1111.png

     

     

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    That's actually part of the Dynamics 365 form, and not actually PCF.

     

    There isn't a supported way of changing the styling of attribute labels, you can try editing the DOM object with javascript but that is highly unsupported at this stage.

  • Verified answer
    PaulM Profile Picture
    Microsoft Employee on at

    You could hide the standard label on the form and generate your own label a part of your control.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I was also lokking into this (still to start, it will be my first custom control ever).

    I'm wondering if adding a label in custom control will give the same experience when resizing the screen than using the default label (level within DOM would be different).

     

  • Hemant Gaur Profile Picture
    Microsoft Employee on at

    Yes it should. When the label is hidden the control gets the full section width instead of half with the label. Reflow, resizing is the same. 

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I'm still struggling with this.

    When the browser screen resizes, the OOB controls get different classes assigned to change heigt, width, ...

    How can I do similar if I have the label in my custom control?

    I couldn't find specifications as what the criteria are.

  • PaulM Profile Picture
    Microsoft Employee on at

    Yeah it is tricky, you need to use similar responsive design triggers and adjust the style for the label as things reflow. This is not so easy, and if the built-in styles change at some point in future, you would have to re-align to that. @hemant - would it be appropriate to assign the built-in styles to the label? I suspect that would be unsupported?


    @binau wrote:

    I'm still struggling with this.

    When the browser screen resizes, the OOB controls get different classes assigned to change heigt, width, ...

    How can I do similar if I have the label in my custom control?

    I couldn't find specifications as what the criteria are.


     

  • bthompson Profile Picture
    Microsoft Employee on at

    @PaulMare Surely a "label" within a component is no different from any other piece of plain (none form input) html within a component.

     

    Given that look and feel is essential for user experience, components really do need the ability to access label formatting (and reformatting) information to ensure custom PCF components look as close as possible to other fields on the form.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Is there somewhere documentation what is supported and what not?

    I found that using context.factory._customControlProperties.systemDefinedProperties.deviceSizeMode.Value would help me determine what layout I have to apply to my label/input if the size of the window changes.

    However, I'l not sure it is supported.

    Only other alternative I see is context.mode.allocatedWidth  (and hardcode the width).

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
Vish WR Profile Picture

Vish WR 914

#2
11manish Profile Picture

11manish 627

#3
Valantis Profile Picture

Valantis 598

Last 30 days Overall leaderboard