Scenario
I was trying to place a quick action button to display custom lightning component to show a PDF. The quick action popup is coming with a default header and footer. The footer has only one cancel action button but, we need to have 3 action buttons, to perform savePDF, emailPDF and cancel.
To achieve this I have created a custom header, body and footer using SLDS styling. But the content is displayed on the modal popup’s body, with some padding and margin.
How to remove the extra padding and margin in the action popup from the component?
I tried multiple workarounds to achieve this.
- Included the CSS style to remove the margin or padding in the .css part of the aura bundle of my component. But, it is not possible to change the parent popup’s style from the child component due to THIS keyword in CSS.
- Included an external stylesheet into the component as a static resource (using ltng:require). It was working fine but the style will be applied to all the quick action popups in the application.
- HTML style tag cannot be used inside a component as it throws an error on saving.
Solution
Lightning provides an aura:html tag to include the HTML elements. The lightning validator does not throw any error when the style tag comes with an aura:html component like below.
<aura:html tag="style">
.cuf-content {
padding: 0 0rem !important;
}
.slds-p-around--medium {
padding: 0rem !important;
}
.slds-modal__content{
height:unset !important;
max-height:unset !important;
}
</aura:html>
This snippet solves the padding and margin issue inside the quick action popup.Please refer the below link to get the details of the aura:html component and leave a comment if you have any doubts.
https://developer.salesforce.com/docs/component-library/overview/components
HTML in Components
For example, the framework automatically converts a standard HTML <div> tag to this component:
<aura:html tag="div" />
You can add HTML markup in components. Note that you must use strict XHTML. For example, use <br/> instead of <br>. You can also use HTML attributes and DOM events, such as onclick.
Warning
Some tags, like <applet> and <font>, aren’t supported.
Unescaping HTML
To output pre-formatted HTML, use aura:unescapedHTML. For example, this is useful if you want to display HTML that is generated on the server and add it to the DOM. You must escape any HTML if necessary or your app might be exposed to security vulnerabilities.
You can pass in values from an expression, such as in <aura:unescapedHtml value="{!v.note.body}"/>.
{!expression} is the framework's expression syntax. For more information, see Using Expressions.
- Supported HTML Tags
The framework supports most HTML tags, including the majority of HTML5 tags.
See Also
'개발자정보' 카테고리의 다른 글
Extending Lightning Components (0) | 2022.04.16 |
---|---|
Age Of ‘Dock’ing (0) | 2022.04.16 |
Salesforce의 하위 탭에서 상위 탭을 새로 고치는 방법 (0) | 2022.04.16 |
Salesforce(세일즈포스) Action Function (0) | 2022.04.16 |
Salesforce(세일즈포스) Current Geolocation Component (0) | 2022.04.16 |