Utility Bar API

lightning:utilityBarApi

Work with a utility within the utility bar of a Lightning app.

For Aura components only. For LWC development, use lightning/platformUtilityBarApi.

For Use In

Lightning Experience

This component allows you to access methods for programmatically controlling a utility within the utility bar of a Lightning app. The utility bar is a footer that gives users quick access to frequently used tools and components. Each utility is a single-column Lightning page that includes a standard or custom Lightning component.

To access the methods, create an instance of the lightning:utilityBarAPI component inside of your utility and assign an aura:id attribute to it.

1<lightning:utilityBarAPI aura:id="utilitybar" />

This example sets the icon of a utility to the SLDS “insert tag field” icon when the button is clicked.

1<aura:component implements="flexipage:availableForAllPageTypes" access="global">
2  <lightning:utilityBarAPI aura:id="utilitybar" />
3  <lightning:button label="Set Utility Icon" onclick="{! c.setUtilityIcon }" />
4</aura:component>

The button in the component calls the following client-side controller.

1({
2  setUtilityIcon: function (component, event, helper) {
3    var utilityAPI = component.find("utilitybar");
4    utilityAPI.setUtilityIcon({ icon: "insert_tag_field" });
5  },
6});

Methods 

This component supports the following methods. Most methods take only one argument, a JSON array of parameters. The utilityId parameter is only optional if within a utility itself. For more information on these methods, see the Console Developer Guide.

getEnclosingUtilityId()

Returns a Promise. Success resolves to the enclosing utilityId or false if not within a utility. The Promise will be rejected on error.

getUtilityInfo({utilityId})

  • utilityId (string): Optional. The ID of the utility for which to get info.

Returns a Promise. Success resolves to a utilityInfo object. The Promise will be rejected on error.

getAllUtilityInfo()

Returns a Promise. Success resolves to an array of utilityInfo objects. The Promise will be rejected on error.

minimizeUtility({utilityId})

  • utilityId (string): Optional. The ID of the utility for which to minimize.

Returns a Promise. Success resolves to true. The Promise will be rejected on error.

onUtilityClick({utilityId, eventHandler})

  • utilityId (string): Optional. The ID of the utility for which to register the callback.
  • eventHandler (function): The JavaScript function that’s called when the utility is clicked.

Returns a Promise. Success resolves to true. The Promise will be rejected on error.

openUtility({utilityId})

  • utilityId (string): Optional. The ID of the utility for which to open.

Returns a Promise. Success resolves to true. The Promise will be rejected on error.

setPanelHeaderIcon({icon, utilityId})

  • icon (string): An SLDS utility icon key. This is displayed in the utility panel. See a full list of utility icon keys on the SLDS reference site.
  • utilityId (string): Optional. The ID of the utility for which to set the panel header icon on.

Returns a Promise. Success resolves to true. The Promise will be rejected on error.

setPanelHeaderLabel({label, utilityId})

  • label (string): The label of the utility displayed in the panel header.
  • utilityId (string): Optional. The ID of the utility for which to set the panel header label on.

Returns a Promise. Success resolves to true. The Promise will be rejected on error.

setPanelHeight({heightPX, utilityId})

  • heightPX (integer): The height of the utility panel in pixels.
  • utilityId (string): Optional. The ID of the utility for which to set the panel height on.
  • durationMs (number): Optional. The time in milliseconds it takes for the height transition to complete. Default value is 0.
  • timingFunction (string): Optional. The transition timing function that sets the rate for panel height changes. Supports any CSS easing function supported by your target browser. Default value is ease.
  • delayMs (number): Optional. The wait time in milliseconds before the height transition starts. Default value is 0.

Returns a Promise. Success resolves to true. The Promise will be rejected on error.

setPanelWidth({widthPX, utilityId})

  • widthPX (integer): The width of the utility panel in pixels.
  • utilityId (string): Optional. The ID of the utility for which to set the panel width on.
  • durationMs (number): Optional. The time in milliseconds it takes for the width transition to complete. Default value is 0.
  • timingFunction (string): Optional. The transition timing function that sets the rate for panel height changes. Supports any CSS easing function supported by your target browser. Default value is ease.
  • delayMs (number): Optional. The wait time in milliseconds before the height transition starts. Default value is 0.

Returns a Promise. Success resolves to true. The Promise will be rejected on error.

disableUtilityPopOut({disabled, disabledText})

  • disabled (boolean): Whether the pop-out and pop-in options are disabled. Set to true to disable pop-out or pop-in for the utility item.
  • disabledText (string): Optional. Used as the hover text and alternative text for the pop-in or pop-out option.

Returns a Promise. Success resolves to true. The Promise will be rejected on error.

setUtilityHighlighted({highlighted, utilityId})

  • highlighted (boolean): Whether the utility is highlighted. Makes a utility more prominent by giving it a different background color.
  • utilityId (string): Optional. The ID of the utility for which to set highlighted.

Returns a Promise. Success resolves to true. The Promise will be rejected on error.

setUtilityIcon({icon, utilityId})

  • icon (string): An SLDS utility icon key. This is displayed in the utility bar. See a full list of utility icon keys on the SLDS reference site.
  • utilityId (string): Optional. The ID of the utility for which to set the icon on.

Returns a Promise. Success resolves to true. The Promise will be rejected on error.

setUtilityLabel({label, utilityId})

  • label (string): The label of the utility. This is displayed in the utility bar.
  • utilityId (string): Optional. The ID of the utility for which to set the label on.

Returns a Promise. Success resolves to true. The Promise will be rejected on error.

toggleModalMode({enableModalMode, utilityId})

  • enableModalMode (boolean): Whether to enable the utility’s modal mode. While in modal mode, an overlay is shown over the whole app that blocks usage while the utility panel is still visible.
  • utilityId (string): Optional. The ID of the utility for which to toggle modal mode.

Returns a Promise. Success resolves to true. The Promise will be rejected on error.

isUtilityPoppedOut()

Returns a Promise. Resolves to true if utility is in a popped out window, false otherwise. Promise will be rejected on an error.

Attributes 

NameDescriptionTypeDefaultRequired
bodyThe body of the component. In markup, this is everything in the body of the tag.Aura.Component[]

Methods 

NameDescriptionArgument NameArgument TypeArgument Description
disableUtilityPopOutSets the utility panel’s pop out enablement state.argumentsObjectArgument object with values for utilityId, disabled, and disabledText.
getAllUtilityInfoReturns information about all utilities as utilityInfo objects.
getEnclosingUtilityIdReturns the enclosing utility id.
getUtilityInfoReturns information about the utility as a utilityInfo object.argumentsObjectArgument object with value for utilityId.
isUtilityPoppedOutDetermines whether the utility is in a popped out window
minimizeUtilityMinimizes the utility.argumentsObjectArgument object with value for utilityId.
onUtilityClickRegisters an eventHandler for the utility. This eventHandler is called when the utility is clicked.argumentsObjectArgument object with value for utilityId and eventHandler.
openUtilityOpens the utility. If the utility is already open, this method has no effect. Only one utility can be open at a time. If another utility is already open, it will be minimized.argumentsObjectArgument object with value for utilityId.
setPanelHeaderIconSets the icon of the utility’s panel. This icon is displayed in the utility panel header.argumentsObjectArgument object with values for utilityId and icon.
setPanelHeaderLabelSets the label of the utility’s panel. This label is displayed in the utility panel header.argumentsObjectArgument object with values for utilityId and label.
setPanelHeightSets the utility panel’s height.argumentsObjectArgument object with values for utilityId, heightPX, [durationMS], [timingFunction], and [delayMS].
setPanelWidthSets the utility panel’s width.argumentsObjectArgument object with values for utilityId, widthPX, [durationMS], [timingFunction], and [delayMS].
setUtilityHighlightedSets a utility as highlighted, giving it a more prominent background color and badge.argumentsObjectArgument object with values for utilityId and highlighted.
setUtilityIconSets the icon of the utility. This icon is displayed in the utility bar.argumentsObjectArgument object with values for utilityId and icon.
setUtilityLabelSets the label of the utility. This text is displayed in the utility bar.argumentsObjectArgument object with values for utilityId and label.
toggleModalModeToggles the utility panel's modal mode.argumentsObjectArgument object with values for utilityId and enableModalMode.