updateUtility() for Lightning Experience

Specifies a label and icon on the utility bar, and sets a utility as highlighted. This method is available for Lightning Web Components (LWC) only.

Arguments

Optional parameters are passed into an object as the last argument of the method.

Name Type Description
utilityId string The ID of the utility to update.
utilityAttrs object Optional. Attributes that specify the appearance of the icon.
  • label—The label of the utility that’s displayed in the utility bar.
  • icon—The Lightning Design System (SLDS) name of the icon in the format einstein, where einstein is the name of the SLDS utility icon. The icon is displayed in the utility bar. See a full list of utility icon keys at the SLDS reference site. SLDS doctype, standard, custom, and action icons aren’t supported.
  • iconVariant—The variant changes the color of the utility bar. Available variants are success (green success color), warning (yellow warning color), and error (red error color).
  • highlighted—Applies a different background color.

LWC Sample Code

Before you can use the LWC utility bar API, Lightning Web Security must be enabled.

This component opens a utility using the enclosing utility ID.

import { LightningElement, wire } from 'lwc';
import { updateUtility, EnclosingUtilityId } from 'lightning/platformUtilityBarApi';

export default class UpdatePanelExample extends LightningElement {
    @wire(EnclosingUtilityId) utilityId;

    utilityAttrs = {
        label: 'Account Insights',
        icon: 'einstein',
        iconVariant: 'success',
        highlighted: true
    }

    handleUpdate() {
        if (this.utilityId) {
            return updateUtility(this.utilityId, this.utilityAttrs);
        }
    }
}

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.