Add icons to QuickPick List

Viewed 1368

I'm currently writing an extension that lists files in a QuickPick dialogue. Is there a way to add the icons to the QuickPickItem's label?

Or in other words, re-use the vscode-icons extension?

1 Answers

As far as I know you cannot reference an svg from something like the vscode-icons extension.

You can use Github Octicons in any of the QuickPickItem properties right out of the box:

const items: vscode.QuickPickItem[] = [{label: '$(git-merge) Merge Branch',
                                        description: '$(git-commit) 1 commit',
                                        detail: '$(diff-added) 3 $(diff-modified) 2'}]
vscode.window.showQuickPick(items)

You can even just pass in an array of strings to showQuickPick:

vscode.window.showQuickPick(['$(diff-added) Add', '$(diff-removed) Remove'])

Related