Now the issue with these modals are it comes with a specific size (height & width) which is not appropriate for all requirements. If you are a good designer who needs a perfect UI then you might think of updating the height and width of the default popup size.
If you are still looking for it, then fortunately you have landed on the right blog. Please follow below steps to increase the size of the LWC Quick Action modal popup.
Step 1 : Create an external css file as shown below :
custommodal.css
1 2 3 4 5 | .slds-modal__container{ width: 90% !important; max-width: 90% !important; } |
Step 2 : Create a static resource in your org and upload the css file.
Step 3 : Import the static resource in your LWC and load the styles on the load of the component using connectedCallback function as shown below :
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 | <template> <lightning-quick-action-panel header="Quick Action Title"> <p>Welcome to SalesforceBolt.com</p> <div slot="footer"> <lightning-button variant="neutral" label="Cancel" onclick={closeAction} ></lightning-button> <lightning-button variant="brand" label="Save"></lightning-button> </div> </lightning-quick-action-panel> </template> |
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 | import { LightningElement } from "lwc"; import modal from "@salesforce/resourceUrl/custommodalcss"; import { CloseActionScreenEvent } from "lightning/actions"; import { loadStyle } from "lightning/platformResourceLoader"; export default class QuickActionLWC extends LightningElement { connectedCallback() { loadStyle(this, modal); } closeAction() { this.dispatchEvent(new CloseActionScreenEvent()); } } |
Output
If you need to update the width then you have to make the changes in the css file and modify the static resource file again.
17 Comments
How can this be applied to the modal for screen flows?
ReplyDeleteI don't think that the functionality is available. Please upvote below idea to support it
Deletehttps://trailblazer.salesforce.com/ideaView?id=0874V000000Pi3bQAC
Thank you so much for this! Just a question...
ReplyDeleteIs there anyway we can even increase the height of the quick action panel beyond the
"height: 100%"
Interesting, maybe you can try it. We might be having horizontal scroll bars in that case.
DeleteThanks it is really helpful for me bcz I am new to LWC, Is there any way to apply on only particular action? bocz it will applied on all actions popup
ReplyDeletePerfect! thanks!
ReplyDeleteGlad it helped !
Deletecan we do it without using static resource?
ReplyDeleteI am afraid not, because it will always give priority to the default css until forced to change using an external one.
DeleteCould another approach be to separate the component and quick action. Use a headless quick action and Lightning message service to publish a message when the quick action is clicked.
ReplyDeletePut your LWC component modal on the lightning page somewhere, subscribed to the message channel. Toggle the visibility when a message is received.
The modal can then be any size you like without affecting any of the standard sf modals
How can I reset the CSS override because it affects the other modals even after closing the modal containing the script?
ReplyDeleteJust remove your CSS references.
Deleteis there any way to remove the resource at moment to close modal?, because when I open another action the css is keeping alive
ReplyDeleteMmm... I don't think so as once it's loaded in the browser it's loaded.
DeleteHey BOLT Thank you for sharing knowledge
ReplyDeleteThanks, glad to hear that you find it helpful!
Deleteit was very much helpful thanks !
ReplyDelete