Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

add icon to activity bar in visual studio code extension

I am new to VSC extension development.

I started with the extension hello world and I want to add an icon to the activity bar and get a notification when it is clicked.

I add these lines to package.json

"viewsContainers": {
            "activitybar": [
                {
                    "id": "package-explorer",
                    "title": "Package Explorer",
                    "icon": "media/my.svg"
                }
            ]
        },

I copied these lines from VSC sample treeView (https://github.com/microsoft/vscode-extension-samples/tree/main/tree-view-sample)

The icon is also copied from the same repository.

When I run the extension, I am not getting any icon in the activity bar. What should I do so this icon appears in the activity bar and how can I be notified if it is clicked?

like image 247
mans Avatar asked Oct 21 '25 12:10

mans


1 Answers

You must also specify a "views" item that matches the id of your viewContainer

Try adding the following right after the "viewsContainers" object in the "contributes" section of package.json

"views": {
    "package-explorer": [
        {
            "id": "VIEW_ID",
            "name": "VIEW_NAME"
        }
    ]
}
like image 143
DAC Avatar answered Oct 24 '25 01:10

DAC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!