Skip to main content

statusBarAPI

MS Code Extension API


MS Code Extension API / core/extensionAPI/modules/window/statusBarAPI

core/extensionAPI/modules/window/statusBarAPI

Interfaces

StatusBarItemAPI

Defined in: core/extensionAPI/modules/window/statusBarAPI.ts:10

Interface representing a Status Bar Item created by an extension. Allows dynamic updates to text, icons, tooltips, and click commands.

Properties

alignment

readonly alignment: StatusBarAlignment

Defined in: core/extensionAPI/modules/window/statusBarAPI.ts:14

The alignment position ('left' or 'right') in the status bar.

color

color: string

Defined in: core/extensionAPI/modules/window/statusBarAPI.ts:23

Updates the foreground color of the item (e.g., 'var(--ms-error)' or '#ff0000').

command

command: string

Defined in: core/extensionAPI/modules/window/statusBarAPI.ts:29

Sets the ID of a registered command to execute when the item is clicked.

Example
myItem.command = 'myExtension.runLinter';
dispose

dispose: () => void

Defined in: core/extensionAPI/modules/window/statusBarAPI.ts:36

Completely removes the item and cleans up memory resources.

Returns

void

hide

hide: () => void

Defined in: core/extensionAPI/modules/window/statusBarAPI.ts:34

Hides the item from the status bar without destroying it.

Returns

void

icon

icon: string

Defined in: core/extensionAPI/modules/window/statusBarAPI.ts:25

Updates the icon displayed next to the text (e.g., 'sync', 'check').

id

readonly id: string

Defined in: core/extensionAPI/modules/window/statusBarAPI.ts:12

The universally unique identifier generated for this item.

priority

readonly priority: number

Defined in: core/extensionAPI/modules/window/statusBarAPI.ts:16

The layout priority. Higher numbers are placed closer to the outer edges.

show

show: () => void

Defined in: core/extensionAPI/modules/window/statusBarAPI.ts:32

Makes the item visible in the status bar.

Returns

void

text

text: string

Defined in: core/extensionAPI/modules/window/statusBarAPI.ts:19

Updates the text/label displayed in the status bar.

tooltip

tooltip: string

Defined in: core/extensionAPI/modules/window/statusBarAPI.ts:21

Updates the hover tooltip text shown to the user.

Functions

createStatusBarAPI()

createStatusBarAPI(extId): object

Defined in: core/extensionAPI/modules/window/statusBarAPI.ts:43

Factory function to create the StatusBar API for a specific extension.

Parameters

extId

string

The unique identifier of the extension creating the status bar item.

Returns

createStatusBarItem

createStatusBarItem: (alignment?, priority?) => StatusBarItemAPI

Creates a new status bar item. The item is initially hidden and must be explicitly shown. *

Parameters
alignment?

StatusBarAlignment = 'left'

Position of the item ('left' or 'right').

priority?

number = 0

Layout priority (higher numbers appear closer to the edges).

Returns

StatusBarItemAPI

An object to control the status bar item's properties. *

Example
// 1. Create the item (aligned left, high priority to be near the edge)
const prettierStatus = mscode.window.createStatusBarItem('left', 100);
* // 2. Configure properties
prettierStatus.text = "Prettier";
prettierStatus.tooltip = "Prettier is running";
prettierStatus.icon = "check";
prettierStatus.command = "prettier.formatDocument";
* // 3. Make it visible
prettierStatus.show();
* // 4. Update it dynamically later (e.g., on error)
prettierStatus.color = "var(--ms-error)";
prettierStatus.icon = "warning";
prettierStatus.tooltip = "Prettier syntax error";
* // 5. Cleanup when extension deactivates
prettierStatus.dispose();