DEV Community

Cover image for Crafting My First VSCode Theme: Relax Theme
Ravi Kishan
Ravi Kishan

Posted on

Crafting My First VSCode Theme: Relax Theme

As a developer, I’ve always appreciated tools that feel personal, especially those I spend the most time with—like VSCode. Customizing its appearance to suit my workflow and preferences became a project I wanted to explore, and that led to the creation of Relax Theme, a fully dark theme designed for fellow programmers. This project wasn't just about creating a theme; it was a way for me to learn how themes in VSCode work, right from structure to publication. You can find the theme live on the VSCode marketplace: Relax Theme.

Why a Dark Theme?

I find that dark themes minimize eye strain, especially during long coding sessions. The idea behind Relax Theme was to create a calming environment, with deep tones that reduce glare while maintaining sharp contrast for readability.

Relax Theme MarketPlace

Relax Theme Sample 1

Relax Theme Sample 2

Relax Theme Sample 2

Learning the VSCode Theme Basics

Themes in VSCode are surprisingly simple once you understand the fundamentals. Here's the basic process I followed to create Relax Theme:

1. Setting Up the Project

To get started, you’ll need to install the Yeoman generator for VSCode extensions. This generator helps scaffold the necessary files for building a theme.

Installation steps:

  1. Make sure you have Node.js installed.
  2. Install the Yeoman tool and the generator for VSCode extensions globally:
   npm install -g yo generator-code
Enter fullscreen mode Exit fullscreen mode
  1. Once installed, create your new theme project by running:
   yo code
Enter fullscreen mode Exit fullscreen mode
  1. Choose the option to create a New Color Theme.
  2. Follow the prompts to define the name, description, and base for your theme (I used a dark base for Relax Theme).

This process will generate a basic project structure with files like package.json and themes/your-theme-color-theme.json, where you define your colors.

2. Defining Colors

At the heart of any theme are the colors you choose for the UI elements. In Relax Theme, I paid close attention to contrast and readability. Here's a peek at the colors.json file where the core colors are defined:

{
  "workbench.colorCustomizations": {
    "editor.background": "#1e1e1e",
    "editor.foreground": "#d4d4d4",
    "sideBar.background": "#252526",
    "activityBar.background": "#333333"
  }
}
Enter fullscreen mode Exit fullscreen mode

The theme relies on a palette of dark grays and a soft highlight for text, making it easy to focus on code.

3. Customizing Syntax Highlighting

Beyond the general interface, customizing syntax highlighting is crucial for a theme's usability. I assigned colors for keywords, variables, and strings to ensure the code stands out clearly while avoiding harsh, bright colors.

{
  "tokenColors": [
    {
      "scope": "keyword",
      "settings": {
        "foreground": "#569cd6"
      }
    },
    {
      "scope": "string",
      "settings": {
        "foreground": "#d69d85"
      }
    }
  ]
}
Enter fullscreen mode Exit fullscreen mode

4. Testing and Tweaking

The real challenge comes in the testing phase. A theme has to look good across different file types and programming languages. I spent a significant amount of time switching between various languages like JavaScript, Python, and Rust, ensuring that Relax Theme was consistently clean and readable.

5. Publishing the Theme

Once I was satisfied with the theme’s look and feel, the next step was to publish it. VSCode extensions are published via the vsce tool.

To install it:

npm install -g vsce
Enter fullscreen mode Exit fullscreen mode

Packaging and publishing the theme:

  1. Run the command to package your theme:
   vsce package
Enter fullscreen mode Exit fullscreen mode
  1. Once packaged, publish it to the VSCode marketplace using:
   vsce publish
Enter fullscreen mode Exit fullscreen mode

To publish, you’ll need to have a Microsoft Azure DevOps account and create a personal access token. After publishing, your theme will be live and accessible for everyone to download.

What I Learned

Creating the Relax Theme helped me understand how the VSCode theming system works from the ground up. Here's a quick summary of my takeaways:

  • Customization: It’s amazing how much control you can have over the editor's appearance.
  • User Experience: Creating a dark theme that strikes the right balance between aesthetics and usability can take time, but it’s worth the effort.
  • Community: Contributing to the VSCode marketplace feels rewarding. It’s a small but meaningful way to share something useful with the developer community.

Source Code

Source Code

Try It Out!

If you’re looking for a soothing, distraction-free theme for your coding sessions, give Relax Theme a try! You can download it from the VSCode Marketplace. I'd love to hear your feedback!


Building this theme was just the beginning of my journey into customizing developer tools. If you're curious about how to make your own theme or want to learn more about the process, feel free to reach out or explore the codebase yourself. Happy coding!

Top comments (0)