{"id":33804,"date":"2023-01-20T12:43:31","date_gmt":"2023-01-20T07:13:31","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=33804"},"modified":"2023-01-20T12:43:31","modified_gmt":"2023-01-20T07:13:31","slug":"applying-css-in-virtual-powerapps-component-framework","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2023\/01\/applying-css-in-virtual-powerapps-component-framework\/","title":{"rendered":"Applying CSS in Virtual PowerApps Component Framework"},"content":{"rendered":"<h2><strong>Introduction<\/strong><\/h2>\n<p>Recently, while working on virtual PowerApps Component Framework control, I faced an issue that my CSS styling was not getting applied in my PCF control.<\/p>\n<p>As I was coming from a standard PCF background, I only knew the standard way of applying CSS just to the control, following the below syntax.<\/p>\n<p>From <strong>ControlManifest.Input.xml<\/strong> take the namespace and constructor and add them to the CSS file before the element.<\/p>\n<pre class=\"lang:css gutter:true start:1\">&lt;control namespace=\"KPI\" constructor=\"LinearInputControl\" version=\"0.0.16\" display-name-key=\"Linear Input Control\"\r\ndescription-key=\"\" control-type=\"standard\" preview-image=\"img\/preview.png\"&gt;<\/pre>\n<p>In the CSS file, we apply CSS as follows, so the styling should be applied to only our control.<\/p>\n<pre class=\"lang:css gutter:true start:1\">.KPI\\.LinearInputControl .className { display: block; padding: 0%; }<\/pre>\n<p><strong><br \/>\nSolution<\/strong><\/p>\n<p>To resolve this issue, I found a way that I would like to share with you all.<\/p>\n<p>Firstly, check the root component, and give the top-most parent element an id. For example, in my main component, the Stack component is my parent element. So I will add an id in that element. Now I can apply my CSS to all the components inside the Stack with the help of this id.<\/p>\n<pre class=\"lang:css gutter:true start:1\">return (\r\n\r\n&lt;Stack dir=\"ltr\" id=\"LinearInputControl\"&gt;\r\n\r\n{\/* Child Components *\/}\r\n\r\n&lt;\/Stack&gt;\r\n\r\n)<\/pre>\n<p>Then use this id in CSS file to apply the styling to its child components. We can also give styling to child components if they are in other files as well.<\/p>\n<p>Now, our CSS in .css file will look as shown below.<\/p>\n<pre class=\"lang:css gutter:true start:1\">#LinearInputControl .className {\r\n\r\ndisplay: block;\r\n\r\npadding: 0%;\r\n\r\n}<\/pre>\n<h2><strong>Conclusion<\/strong><\/h2>\n<p>Hence, we learned how to apply CSS in virtual PCF control.<\/p>\n<p><img decoding=\"async\" class=\"alignnone size-full wp-image-33807\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/01\/Business-Process-Checklist-2.png\" alt=\"Business Process Checklist\" width=\"800\" height=\"200\" srcset=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/01\/Business-Process-Checklist-2.png 800w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/01\/Business-Process-Checklist-2-300x75.png 300w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/01\/Business-Process-Checklist-2-768x192.png 768w, https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2023\/01\/Business-Process-Checklist-2-660x165.png 660w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Recently, while working on virtual PowerApps Component Framework control, I faced an issue that my CSS styling was not getting applied in my PCF control. As I was coming from a standard PCF background, I only knew the standard way of applying CSS just to the control, following the below syntax. From ControlManifest.Input.xml take\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2023\/01\/applying-css-in-virtual-powerapps-component-framework\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1],"tags":[2130],"class_list":["post-33804","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-powerapps-component-framework"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/33804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=33804"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/33804\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=33804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=33804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=33804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}