Lightning web component framework now has introduced the standard component
for creating modals, i. e. lightning-quick-action-panel
. Now you
don't need to create modals from SLDS Blueprint. In this post, I will share
the sample code the create LWC Quick action with the Lightning Quick Action
Panel component from the LWC framework.
Let's do it step by step.
Create component
quickActionPanelDemo.html
1
2
3
4
5
6
7
8
9
10
|
<template>
<lightning-quick-action-panel header="My action">
Here's some content for the modal body.
Put your logic here
<div slot="footer">
<lightning-button variant="neutral" label="Cancel"></lightning-button>
<lightning-button variant="brand" label="Save" class="slds-m-left_x-small"></lightning-button>
</div>
</lightning-quick-action-panel>
</template>
|
quickActionPanelDemo.js
1
2
3
4
|
import { LightningElement } from 'lwc';
export default class QuickActionPanelDemo extends LightningElement {
}
|
quickActionPanelDemo.js-meta.xml
1
2
3
4
5
6
7
8
9
10
|
<?xml version="1.0"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
<apiVersion>51.0</apiVersion>
<isExposed>true</isExposed>
<masterLabel>Quick Action Panel Demo</masterLabel>
<description>Quick Action Panel Demo</description>
<targets>
<target>lightning__RecordAction</target>
</targets>
</LightningComponentBundle>
|
Create quick action
- Go to Salesforce Setup and then Object Manager.
-
Search for your desired object, I will use the Contact object for this demo.
-
Go to Buttons, Links, and Actions and click New Action.
- Select action type as Lightning web component.
-
Select your Lightning Web Component name from the drop-down.
-
Give your action a Label, Name.
- Click Save.
-
Then go to the page layout and add your action in the Mobile & Lightning Actions
section.
- Now go and see the output.
Output
No comments :
Post a Comment
Hi there, comments on this site are moderated, you might need to wait until your comment is published. Spam and promotions will be deleted. Sorry for the inconvenience but we have moderated the comments for the safety of this website users. If you have any concern, or if you are not able to comment for some reason, email us at rahul@forcetrails.com