Introducing the getNavItems (Beta) wire adapter for easier navigation menu retrieval!


Now you can easily retrieve the items in the navigation menu using the getNavItems wire adapter.

To use this wire adapter, simply import it into your Lightning web component and specify the necessary parameters. 

Here's an example:

import { LightningElement, wire } from 'lwc';
import { getNavItems } from 'lightning/uiAppsApi';
import FORM_FACTOR from '@salesforce/client/formFactor';

export default class Example extends LightningElement {
  @api tabs = ['standard-Account', 'standard-CollaborationGroup'];
  @wire(getNavItems, {
    formFactor: FORM_FACTOR,
    navItemNames: '$tabs',
    pageSize: 30,
  })
  propertyOrFunction;
}

The getNavItems wire adapter takes in the following parameters:

1. formFactor: 

This parameter is optional and allows you to specify the form factor for which you want to retrieve navigation items. 

The options include: 
   - Large (default for desktop display size)
   - Medium (for tablet display size)
   - Small (for phone display size)

2. navItemNames: 

This parameter is optional and allows you to specify a comma-delimited list of TabDefinition name values to include in the response. 

If not specified, all navigation items for the specified form factor will be included.

3. page: 

This parameter is optional and allows you to specify the page offset from which to begin returning navigation items. 

The default value is 0, which returns items from the first page.

4. pageSize: 

This parameter is optional and allows you to specify the maximum number of navigation items to return on a page. 

The default value is 25.

The propertyOrFunction is a private property or function that receives the stream of data from the wire service. 

If a property is decorated with @wire, the results are returned to the property’s data property or error property. 

If a function is decorated with @wire, the results are returned in an object with a data property and an error property.

Follow Us

Posted By : Sudeer Kamat Date :

view_module Related

label Labels

Comments 0