Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
EnclosingUtilityId Context Wire Adapter for Lightning Experience
To obtain the ID of the enclosing utility, use this context wire adapter. If a caller component isn’t using the wire adapter inside a panel, the enclosing utility ID is null.
LWC Sample Code
This component minimizes a utility bar panel using the enclosing utility ID and the minimize() method.
1import { LightningElement, wire } from 'lwc';
2import { EnclosingUtilityId, minimizeUtility } from 'lightning/platformUtilityBarApi';
3
4export default class MinimizeUtilityExample extends LightningElement {
5 @wire(EnclosingUtilityId) utilityId;
6
7 handleClick() {
8 if (!this.utilityId) {
9 return;
10 }
11 // Minimize the utility bar panel
12 minimize(this.utilityId);
13 }
14}To make your component available for use in a utility bar, specify the lightning__UtilityBar target in the component’s configuration file.
Response
Returns the enclosing utility ID if the caller component is within a utility, or null otherwise.