enableModal() for Lightning Experience

Toggles modal mode for a utility. While in modal mode, an overlay blocks users from using the console while the utility panel is visible. This method is available for Lightning Web Components (LWC) only.

Arguments 

NameTypeDescription
utilityIdstringThe ID of the utility for which to toggle modal mode.
enabledbooleanSpecifies whether to enable the utility’s modal mode.

LWC Sample Code 

This component toggles modal mode in a utility bar.

1import { LightningElement, wire } from 'lwc';
2import { enableModal, EnclosingUtilityId } from 'lightning/platformUtilityBarApi';
3
4export default class EnableModalExample extends LightningElement {
5    @wire(EnclosingUtilityId) utilityId;
6    isModalEnabled = false;
7    
8    async handleToggle() {
9        const enable = !this.isModalEnabled;
10        this.isModalEnabled = enable;
11        await enableModal(this.utilityId, enable);
12    }
13}

To make your component available for use in a utility bar, specify the lightning__UtilityBar target in the component’s configuration file.

Response 

Returns a promise that resolves to true if successful. The promise is rejected on error.