Sub topic 6
Laying out the panel with lightning-quick-action-panel
This chapter covers the markup of a screen action. It assumes you know the basic LWC file structure, @api, and event handling, and that you have already exposed the component with lightning__RecordAction and actionType set to ScreenAction.
What the component does
A screen action opens in a modal that the platform draws for you. lightning-quick-action-panel supplies the layout inside that modal: a header, a scrolling body, and a footer. Using it makes your action look like the standard actions, and it follows the platform's spacing and responsive behavior.
The component has one attribute and one slot:
| Part | Type | Purpose |
|---|---|---|
| `header` | attribute | Text shown as the title of the panel |
| default slot | content | Everything you place directly inside the tag becomes the body |
| `footer` | named slot | Buttons or other content pinned to the bottom |
A working template
The template below puts a text area in the body and two buttons in the footer.
<template>
<lightning-quick-action-panel header="Update Description">
<lightning-textarea
label="Description"
value={description}
onchange={handleChange}>
</lightning-textarea>
<div slot="footer">
<lightning-button variant="neutral" label="Cancel" onclick={handleCancel}></lightning-button>
<lightning-button variant="brand" label="Save" onclick={handleSave} disabled={isSaving}></lightning-button>
</div>
</lightning-quick-action-panel>
</template>Three details matter here.
- The
headervalue is a plain string. It is not translated for you, so use a custom label if your org supports several languages. - Anything without a
slotattribute goes to the body. Thelightning-textareahas no slot, so it lands there. - The footer content must carry
slot="footer". A common choice is adiv, so that several buttons share one slot.
The Save button is bound to disabled={isSaving}. The class sets isSaving to true before the save starts and back to false in a finally block. This stops a second click from sending a duplicate request while the first one is in flight.
How the pieces fit together
Button conventions
Salesforce's standard actions use a neutral Cancel button on the left and a brand Save button on the right. The variant attribute controls this: neutral gives the grey outlined style, and brand gives the blue filled style. Keep to this pattern so users do not have to relearn your action.
Common mistakes
- Using the panel in a headless action. A headless action has no UI, so it does not render a template. The panel belongs only in screen actions.
- Forgetting the footer slot name. Buttons placed without
slot="footer"appear inside the body, directly under the fields, and are not pinned to the bottom. - Building your own modal. Do not wrap your content in a custom modal. The platform already provides one, and the result is a modal inside a modal.
- Wiring the buttons to nothing. The panel does not close itself.
Cancelmust dispatchCloseActionScreenEvent, which a later chapter covers in detail.
Try it
Exercise
A developer adds two buttons to a quick action panel but forgets to set slot="footer" on their wrapper. Where do the buttons appear, and what is the fix?
Show answer
They appear in the body, directly after the fields, instead of pinned at the bottom. Wrap them in an element such as a div with slot="footer" so the panel places them in the footer region.
Exercise
Why is the Save button bound to disabled={isSaving}, and where should isSaving be set back to false?
Show answer
Disabling the button while the save is running prevents duplicate submissions from repeated clicks. isSaving should be reset in a finally block so the button is enabled again whether the save succeeds or fails.