After adding app icons to the quick bar, you can customize the shortcut menu category, window category, icon, and progress bar of the app.
Since API version 26.0.0, you can query whether the quick bar is supported and customize the icon and progress bar of the app in the quick bar.
Since API version 6.1.0(23), you can customize the window category of the app in the quick bar.
Since API version 6.0.2(22), you can customize the menu category of the app in the quick bar.
The quick bar refers to the icon area at the bottom of the screen on a PC/2-in-1 device, as shown in the following figure.

After an app icon is added to the quick bar, the icon menu will display the customized menu items. You can add, delete, update, and query menu items. The following is an example.

The following lists the APIs related to operating an app icon in the quick bar. For details, please refer to the API Reference.
The APIs provided by Desktop Extension Kit take effect only on PCs/2-in-1 devices.
Table 1 APIs related to operating an app icon in the quick bar
| API | Description |
|---|---|
| getCustomCategories(context: common.Context): Promise<CustomCategory[]> | Obtains all categories defined in the quick bar menu. |
| addCustomCategory(context: common.Context, categoryName: string): Promise<CustomCategory> | Adds a quick bar menu category. |
| updateCustomCategory(context: common.Context, category: CustomCategory): Promise<void> | Updates a quick bar menu category. |
| deleteCustomCategory(context: common.Context, categoryId: number): Promise<void> | Deletes a quick bar menu category. |
| getTasksFromCategory(context: common.Context, categoryId: number): Promise<QuickTask[]> | Obtains all tasks in a quick bar menu category. |
| addQuickTask(context: common.Context, categoryId: number, taskInfo: QuickTaskInfo): Promise<QuickTask> | Adds a quick bar menu task. |
| updateQuickTask(context: common.Context, task: QuickTask): Promise<void> | Updates a quick bar menu task. |
| deleteQuickTask(context: common.Context, taskId: number): Promise<void> | Deletes a quick bar menu task. |
| addQuickBarGroup(context: common.Context, group: QuickBarGroup): Promise<void> | Adds a quick bar category. |
| deleteQuickBarGroup(context: common.Context, groupKey: string): Promise<void> | Deletes a quick bar category. |
| getQuickBarGroups(context: common.Context): Promise<QuickBarGroup[]> | Obtains information about all categories. |
| setWindowToGroup(context: common.Context, windowid:string, groupKey?: string): Promise<void> | Adds a window to a category. |
| setQuickBarCombineIcon(context: common.Context, combineIcon: image.PixelMap): Promise<void> | Sets the quick bar converged icon. |
| setQuickBarLayeredIcon(context: common.Context, foregroundIcon: image.PixelMap, backgroundIcon: image.PixelMap): Promise<void> | Sets the quick bar layered icon. |
| setProgressState(context: common.Context, state: ProgressState): Promise<void> | Sets the progress bar status of the quick bar. |
| setProgressValue(context: common.Context, completed: number, total: number): Promise<void> | Sets the progress bar of the quick bar icon. |
| isQuickBarCapabilitySupported(context: common.Context): Promise<boolean> | Checks whether the quick bar capability is supported. |
Import required modules.
import { quickBarManager } from '@kit.DeskTopExtensionKit'; Call isQuickBarCapabilitySupported to check whether the current device supports the quick bar. You can customize the menu category, window category, icon, and progress bar of the quick bar only when the value of isSupport is true.
let context: Context | undefined = this.getUIContext().getHostContext();
if (context === undefined) {
return;
}
try {
const isSupport = await quickBarManager.isQuickBarCapabilitySupported(context);
console.info(`isQuickBarCapabilitySupported: ${isSupport}`);
} catch (error) {
console.error(`isQuickBarCapabilitySupported failed. error code: ${error.code}, error message: ${error.message}`);
} Import required modules.
import { quickBarManager } from '@kit.DeskTopExtensionKit';
import { resourceManager } from '@kit.LocalizationKit';
import { image } from '@kit.ImageKit'; Call setQuickBarCombineIcon to set the converged icon for the quick bar.
let context: Context | undefined = this.getUIContext().getHostContext();
if (context === undefined) {
return;
}
try {
// Obtain a resource manager.
const resourceMgr: resourceManager.ResourceManager = context.resourceManager;
// Create pixelMap for the icon. You need to place the icon.png image in the rawfile folder beforehand.
const fileData = resourceMgr.getRawFileContentSync('icon.png');
const imageSource = image.createImageSource(fileData.buffer);
const imagePixelMap = await imageSource.createPixelMap();
await quickBarManager.setQuickBarCombineIcon(context, imagePixelMap);
console.info('setQuickBarCombineIcon success');
} catch (error) {
console.error(`setQuickBarCombineIcon failed. error code: ${error.code}, error message: ${error.message}`);
} Call setQuickBarLayeredIcon to set the layered icon for the quick bar.
let context: Context | undefined = this.getUIContext().getHostContext();
if (context === undefined) {
return;
}
try {
// Obtain a resource manager.
const resourceMgr: resourceManager.ResourceManager = context.resourceManager;
// Create pixelMap for the foreground image. You need to place the foreground.png image in the rawfile folder beforehand.
const foregroundFileData = resourceMgr.getRawFileContentSync('foreground.png');
const foregroundImageSource = image.createImageSource(foregroundFileData.buffer);
const foregroundPixelMap = await foregroundImageSource.createPixelMap();
// Create pixelMap for the background image. You need to place the background.png image in the rawfile folder beforehand.
const backgroundFileData = resourceMgr.getRawFileContentSync('background.png');
const backgroundImageSource = image.createImageSource(backgroundFileData.buffer);
const backgroundPixelMap = await backgroundImageSource.createPixelMap();
await quickBarManager.setQuickBarLayeredIcon(context, foregroundPixelMap, backgroundPixelMap);
console.info('setQuickBarLayeredIcon success');
} catch (error) {
console.error(`setQuickBarLayeredIcon failed. error code: ${error.code}, error message: ${error.message}`);
} Call setProgressValue to set the progress bar in the quick bar. If the progress bar status is not set before this API is called, the default status is NORMAL.
let context: Context | undefined = this.getUIContext().getHostContext();
if (context === undefined) {
return;
}
const completed: number = 50;
const total: number = 100;
try {
await quickBarManager.setProgressValue(context, completed, total);
console.info('setProgressValue success');
} catch (error) {
console.error(`setProgressValue failed. error code: ${error.code}, error message: ${error.message}`);
} Call setProgressState to set the progress bar status for the quick bar.
let context: Context | undefined = this.getUIContext().getHostContext();
if (context === undefined) {
return;
}
try {
// Set the progress status to PAUSED.
await quickBarManager.setProgressState(context, quickBarManager.ProgressState.PAUSED);
console.info('setProgressState success');
} catch (error) {
console.error(`setProgressState failed. error code: ${error.code}, error message: ${error.message}`);
}