DEV Community

Cover image for How to Create and Deploy a Custom Theme for VS Code
Sh Raj
Sh Raj

Posted on • Originally published at github.com

How to Create and Deploy a Custom Theme for VS Code

How to Create and Deploy a Custom Theme for VS Code

Creating a custom theme for Visual Studio Code (VS Code) allows you to personalize your development environment and share your unique aesthetic with the community. This guide will walk you through the steps to create, package, and deploy a custom theme on the VS Code Marketplace.

Try My Created Theme :- Shade Theme
Image description

Step 1: Set Up Your Development Environment

Before you start, make sure you have the following tools installed:

You will also need to install Yeoman and the Visual Studio Code Extension Generator:

npm install -g yo generator-code
Enter fullscreen mode Exit fullscreen mode

Step 2: Generate the Theme Extension

Use Yeoman to generate a new theme extension:

yo code
Enter fullscreen mode Exit fullscreen mode

Follow the prompts:

  • Select New Color Theme.
  • Enter a name for your theme.
  • Choose Dark or Light based on your preference.
  • Decide whether to start with an existing theme or start fresh.

This will generate a new directory with the necessary files for your theme extension.

Step 3: Customize Your Theme

Navigate to the generated directory and open it in VS Code. The main file you'll be working with is themes/YourThemeName-color-theme.json. This JSON file defines the colors for various UI components and syntax highlighting.

Here's a basic example of what the JSON structure looks like:

{
  "name": "YourThemeName",
  "type": "dark",
  "colors": {
    "editor.background": "#1E1E1E",
    "editor.foreground": "#D4D4D4",
    "activityBar.background": "#333333"
  },
  "tokenColors": [
    {
      "scope": "comment",
      "settings": {
        "foreground": "#6A9955"
      }
    },
    {
      "scope": "keyword",
      "settings": {
        "foreground": "#569CD6"
      }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

Customize the colors to match your desired theme. You can refer to the VS Code Theme Color Reference for a list of customizable properties.

Ad.

Step 4: Test Your Theme

To see your changes in action, press F5 to open a new VS Code window with your theme applied. Make adjustments as needed by editing the YourThemeName-color-theme.json file and restarting the window.

Step 5: Package Your Theme

Once you're satisfied with your theme, it's time to package it for deployment. First, install the vsce tool, which is used to package and publish VS Code extensions:

npm install -g vsce
Enter fullscreen mode Exit fullscreen mode

In the root of your theme project, run the following command to create a .vsix file:

vsce package
Enter fullscreen mode Exit fullscreen mode

This command generates a .vsix file that you can use to install the theme locally or publish it to the Marketplace.

Step 6: Publish Your Theme

To publish your theme, you need to create a publisher account on the Visual Studio Code Marketplace.

Create a Publisher

  1. Visit the Publisher Management page.
  2. Click on New Publisher and follow the instructions to create your publisher profile.

Generate a Personal Access Token

  1. Go to the Azure DevOps page.
  2. Click on your profile picture and select Security.
  3. Under Personal access tokens, click New Token.
  4. Name your token, set the expiration date, and select All accessible organizations.
  5. Click Create and copy the generated token.

Publish the Theme

Use the vsce tool to publish your theme. Run the following command, replacing your-publisher-name with your publisher name:

vsce publish --pat <your_personal_access_token>
Enter fullscreen mode Exit fullscreen mode

You can also automate this step by saving your publisher name and personal access token in the package.json:

"publisher": "your-publisher-name"
Enter fullscreen mode Exit fullscreen mode

Then, run:

vsce publish
Enter fullscreen mode Exit fullscreen mode

Your theme should now be available on the Visual Studio Code Marketplace.

Step 7: Update and Maintain Your Theme

To update your theme, make changes to the YourThemeName-color-theme.json file, increment the version number in the package.json file, and run the vsce publish command again.


GitHub logo SH20RAJ / shade-vscode-theme

Shade Theme is a modern, dark theme for Visual Studio Code with a sophisticated shadow aesthetic

Shade Theme for VS Code

Visitors

Shade Theme

Introduction

Shade Theme is a modern, dark theme for Visual Studio Code with a sophisticated shadow aesthetic. Designed to reduce eye strain and enhance code readability, it offers a unique blend of vibrant colors and subtle contrasts.

Features

  • Dark background to reduce eye strain
  • High contrast for better readability
  • Vibrant colors for syntax highlighting
  • Supports a wide range of languages and file types

Installation

From Visual Studio Code Marketplace

  1. Open Extensions sidebar panel in VS Code. View β†’ Extensions
  2. Search for Shade Theme
  3. Click Install to install it
  4. Click Reload to reload your editor
  5. Navigate to File > Preferences > Color Theme and select Shade Theme

From GitHub

  1. Download the latest Shade Theme release.
  2. Open the Extensions sidebar in VS Code.
  3. Click the ... button at the top-right corner of the Extensions pane and select Install from VSIX....
  4. Select the downloaded .vsix file.
…

By following these steps, you can create, customize, and share your very own VS Code theme. Happy theming!

Top comments (0)