Configure a Component for Quick Actions

On this page, we’ll walk through how to set up a Lightning web component to perform a quick action on a record page. This process has two parts: updating the component’s XML metadata and creating a quick action in Salesforce Setup.

You can use a Lightning web component as a quick action on record pages only. You can’t use a Lightning web component as a global quick action.

Note

Define Component Metadata in its Configuration File 

Your component’s project folder must include a componentName.js-meta.xml configuration file that defines the component’s metadata. To use the component as a quick action, update the file as follows.

  1. In the targets section, add lightning__RecordAction as a target to define the Lightning web component as a quick action on a record page.
  2. Add a targetConfig and set targets to lightning__RecordAction.
  3. To define the quick action type, set actionType to ScreenAction for a screen quick action or Action for a headless quick action. If you don’t specify actionType, the quick action defaults to a screen action.

This configuration file defines a screen action.

1<?xml version="1.0" encoding="UTF-8" ?>
2<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
3  <apiVersion>52.0</apiVersion>
4  <isExposed>true</isExposed>
5  <targets>
6    <target>lightning__RecordAction</target>
7  </targets>
8  <targetConfigs>
9    <targetConfig targets="lightning__RecordAction">
10      <actionType>ScreenAction</actionType>
11    </targetConfig>
12  </targetConfigs>
13</LightningComponentBundle>

This configuration file defines a headless action.

1<?xml version="1.0" encoding="UTF-8" ?>
2<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
3  <apiVersion>52.0</apiVersion>
4  <isExposed>true</isExposed>
5  <targets>
6    <target>lightning__RecordAction</target>
7  </targets>
8  <targetConfigs>
9    <targetConfig targets="lightning__RecordAction">
10      <actionType>Action</actionType>
11    </targetConfig>
12  </targetConfigs>
13</LightningComponentBundle>

You can’t change the action type after you’ve defined it in your Lightning web component. For example, a component’s action type can’t be changed from Action to ScreenAction or vice versa.

Note

See the complete list of XML Configuration File Elements.

Create a Quick Action in Salesforce Setup 

In Salesforce Setup, create object-specific actions via the Object Manager page.

Screenshot of the Buttons, Links, and Actions page for the Account object.

Then add the action to the Salesforce Mobile and Lightning Experience Actions section of your page layout.

Screenshot of the Salesforce Mobile and Lightning Experience Actions section for an Account object page.

For more information, see Salesforce Help: Actions in Lightning Experience. The Empower Your Users with Quick Actions page of the Lightning Experience Customization Trailhead module also describes this Setup step in detail.

Using a Lightning web component as a quick action isn’t supported in the Salesforce mobile app.

Note

See Also