← Back to DevBytes

VS Code Themes and Customization: Complete Guide

Introduction to VS Code Themes and Customization

Visual Studio Code has become one of the most popular code editors in the world, and a big reason for that is its deep customization capabilities. Themes and customization options allow developers to tailor the editor to their personal preferences, improve readability, reduce eye strain during long coding sessions, and even boost productivity through carefully chosen color cues.

In this complete guide, we will explore everything from installing pre-built themes to creating your own custom theme from scratch. We will also cover workspace settings, icon themes, font customization, and advanced tips that will help you master the visual side of VS Code.

What Are VS Code Themes?

A VS Code theme is a collection of color and styling rules that define how the editor looks. Themes control the colors of the editor background, text, syntax highlighting, activity bar, status bar, sidebar, terminal, and many other UI components. There are two main types of themes in VS Code:

Themes are distributed as extensions through the VS Code Marketplace, but you can also create local theme files without publishing them.

Why Theme Customization Matters

Customizing your editor is not just about aesthetics. There are several practical benefits:

Installing and Switching Themes

Installing a Theme from the Marketplace

The easiest way to get started with themes is to install one from the VS Code Marketplace. You can do this directly from the editor:

  1. Open the Extensions view by pressing Ctrl+Shift+X (Windows/Linux) or Cmd+Shift+X (Mac).
  2. Search for "theme" or a specific theme name like "Dracula" or "One Dark Pro".
  3. Click Install on the theme you want.
  4. After installation, VS Code may prompt you to set it as your current theme.

Switching Between Themes

To switch between installed themes, use the Command Palette:

  1. Press Ctrl+K Ctrl+T or open the Command Palette with Ctrl+Shift+P.
  2. Type "Color Theme" and select "Preferences: Color Theme".
  3. Use the arrow keys to preview themes and press Enter to select one.

You can also set your theme directly in your settings JSON file:

{
  "workbench.colorTheme": "Dracula",
  "workbench.iconTheme": "material-icon-theme"
}

Understanding the settings.json File

VS Code stores user preferences in a settings.json file. You can open it by pressing Ctrl+Shift+P and selecting "Preferences: Open User Settings (JSON)". This file is where most customization happens.

Here is an example of a customized settings file:

{
  "workbench.colorTheme": "One Dark Pro",
  "workbench.iconTheme": "vs-seti",
  "editor.fontFamily": "'Fira Code', 'Consolas', monospace",
  "editor.fontLigatures": true,
  "editor.fontSize": 14,
  "editor.lineHeight": 22,
  "editor.fontWeight": "400",
  "editor.cursorBlinking": "smooth",
  "editor.cursorSmoothCaretAnimation": "on",
  "editor.smoothScrolling": true,
  "editor.minimap.enabled": false,
  "workbench.colorCustomizations": {
    "editor.background": "#1e1e2e",
    "editor.foreground": "#cdd6f4",
    "activityBar.background": "#181825",
    "sideBar.background": "#181825",
    "statusBar.background": "#11111b"
  }
}

Customizing Colors Without a Full Theme

If you like an existing theme but want to tweak a few colors, you do not need to create a full theme extension. VS Code allows you to override specific colors using the workbench.colorCustomizations setting.

{
  "workbench.colorCustomizations": {
    "editor.background": "#282c34",
    "editor.lineHighlightBackground": "#2c313c",
    "editor.selectionBackground": "#3e4451",
    "editorCursor.foreground": "#528bff",
    "editorWhitespace.foreground": "#3b4048",
    "activityBarBadge.background": "#528bff",
    "button.background": "#528bff",
    "statusBar.background": "#21252b",
    "statusBar.noFolderBackground": "#21252b"
  }
}

Customizing Syntax Highlighting Colors

You can also override syntax token colors using editor.tokenColorCustomizations. This lets you change how specific language tokens like keywords, strings, and comments are colored.

{
  "editor.tokenColorCustomizations": {
    "comments": "#6a737d",
    "keywords": "#c678dd",
    "strings": "#98c379",
    "numbers": "#d19a66",
    "types": "#61afef",
    "functions": "#61afef",
    "variables": "#e06c75",
    "textMateRules": [
      {
        "scope": "entity.name.function",
        "settings": {
          "foreground": "#61afef",
          "fontStyle": "bold"
        }
      },
      {
        "scope": "support.function",
        "settings": {
          "foreground": "#56b6c2"
        }
      }
    ]
  }
}

Creating Your Own Theme Extension

Step 1: Generate the Theme Project

VS Code provides a Yeoman generator that scaffolds a new theme extension. First, install the required tools globally:

npm install -g yo generator-code

Then run the generator:

yo code

Select "New Color Theme" from the options. The generator will ask you a series of questions:

Step 2: Understand the Theme File Structure

After scaffolding, your project will have a structure similar to this:

my-theme/
├── .vscode/
│   └── launch.json
├── themes/
│   └── my-theme-color-theme.json
├── package.json
├── CHANGELOG.md
├── README.md
└── vsc-extension-quickstart.md

The most important file is the theme JSON file inside the themes/ folder. This is where all your color definitions live.

Step 3: Define Your Theme Colors

Open the theme JSON file. It contains two main sections: colors for the UI and tokenColors for syntax highlighting.

{
  "name": "My Custom Theme",
  "type": "dark",
  "semanticHighlighting": true,
  "colors": {
    "editor.background": "#1a1b26",
    "editor.foreground": "#a9b1d6",
    "editorLineNumber.foreground": "#3b4261",
    "editorLineNumber.activeForeground": "#7aa2f7",
    "editor.selectionBackground": "#33467c",
    "editor.lineHighlightBackground": "#1f2335",
    "editorCursor.foreground": "#c0caf5",
    "editorWhitespace.foreground": "#3b4261",
    "editorIndentGuide.background": "#292e42",
    "editorIndentGuide.activeBackground": "#3b4261",
    "activityBar.background": "#16161e",
    "activityBar.foreground": "#7aa2f7",
    "activityBarBadge.background": "#7aa2f7",
    "sideBar.background": "#16161e",
    "sideBar.foreground": "#a9b1d6",
    "statusBar.background": "#16161e",
    "statusBar.foreground": "#7aa2f7",
    "titleBar.activeBackground": "#16161e",
    "titleBar.activeForeground": "#a9b1d6",
    "terminal.background": "#16161e",
    "terminal.foreground": "#a9b1d6"
  },
  "tokenColors": [
    {
      "scope": "comment",
      "settings": {
        "foreground": "#565f89",
        "fontStyle": "italic"
      }
    },
    {
      "scope": "keyword",
      "settings": {
        "foreground": "#bb9af7"
      }
    },
    {
      "scope": "string",
      "settings": {
        "foreground": "#9ece6a"
      }
    },
    {
      "scope": "constant.numeric",
      "settings": {
        "foreground": "#ff9e64"
      }
    },
    {
      "scope": "entity.name.function",
      "settings": {
        "foreground": "#7aa2f7"
      }
    },
    {
      "scope": "entity.name.type",
      "settings": {
        "foreground": "#2ac3de"
      }
    },
    {
      "scope": "variable",
      "settings": {
        "foreground": "#c0caf5"
      }
    },
    {
      "scope": "variable.parameter",
      "settings": {
        "foreground": "#e0af68"
      }
    },
    {
      "scope": "punctuation",
      "settings": {
        "foreground": "#89ddff"
      }
    }
  ]
}

Step 4: Configure package.json

The package.json file must declare your theme as a contribution. The generator handles most of this, but you should verify the contributes section:

{
  "name": "my-custom-theme",
  "displayName": "My Custom Theme",
  "description": "A beautiful dark theme for VS Code",
  "version": "0.0.1",
  "engines": {
    "vscode": "^1.60.0"
  },
  "categories": ["Themes"],
  "contributes": {
    "themes": [
      {
        "label": "My Custom Theme",
        "uiTheme": "vs-dark",
        "path": "./themes/my-theme-color-theme.json"
      }
    ]
  }
}

Step 5: Test Your Theme

To test your theme during development, press F5 in VS Code. This opens a new Extension Development Host window with your theme loaded. You can switch to your theme using the Color Theme command in that window.

Any changes you make to the theme JSON file will be reflected immediately when you reload the window. Use the Command Palette and run "Developer: Reload Window" to apply changes.

Step 6: Package and Publish

To package your theme for distribution, install the VS Code extension packaging tool:

npm install -g @vscode/vsce

Then create a VSIX package:

vsce package

This generates a .vsix file that can be installed locally or published to the Marketplace. To publish, you need a Personal Access Token from the Azure DevOps portal:

vsce publish

File Icon Themes

Icon themes control the icons shown next to files and folders in the Explorer view. Popular icon themes include Material Icon Theme, VSCode Great Icons, and Seti. You can install them the same way as color themes.

To set an icon theme in your settings:

{
  "workbench.iconTheme": "material-icon-theme"
}

You can also create your own icon theme. An icon theme is defined by a JSON file that maps file names, extensions, and folder names to icon images. Here is a simplified example:

{
  "iconDefinitions": {
    "_folder": {
      "iconPath": "./icons/folder.svg"
    },
    "_folder_open": {
      "iconPath": "./icons/folder-open.svg"
    },
    "_file": {
      "iconPath": "./icons/file.svg"
    },
    "_js": {
      "iconPath": "./icons/javascript.svg"
    },
    "_json": {
      "iconPath": "./icons/json.svg"
    }
  },
  "folder": "_folder",
  "folderExpanded": "_folder_open",
  "file": "_file",
  "fileExtensions": {
    "js": "_js",
    "mjs": "_js",
    "json": "_json"
  },
  "languageIds": {
    "javascript": "_js",
    "json": "_json"
  }
}

Register the icon theme in your package.json:

{
  "contributes": {
    "iconThemes": [
      {
        "id": "my-icon-theme",
        "label": "My Icon Theme",
        "path": "./icons/my-icon-theme.json"
      }
    ]
  }
}

Font Customization

Choosing the right font can significantly improve your coding experience. Popular programming fonts include Fira Code, JetBrains Mono, Cascadia Code, and Source Code Pro. Many of these support ligatures, which combine characters like === or => into a single visual symbol.

Here is how to configure fonts in your settings:

{
  "editor.fontFamily": "'JetBrains Mono', 'Fira Code', 'Courier New', monospace",
  "editor.fontLigatures": true,
  "editor.fontSize": 14,
  "editor.lineHeight": 21,
  "editor.fontWeight": "400",
  "editor.letterSpacing": 0.5,
  "terminal.integrated.fontFamily": "'JetBrains Mono'",
  "terminal.integrated.fontSize": 13
}

After installing a font on your system, you may need to restart VS Code for it to be detected.

Advanced Customization Techniques

Workspace-Specific Themes

You can set different themes for different projects by creating a workspace settings file. Create a .vscode/settings.json file in your project root:

{
  "workbench.colorTheme": "GitHub Light",
  "workbench.iconTheme": "seti"
}

This overrides your global settings only when you open that specific workspace.

Customizing the Title Bar and Product Icon

VS Code also allows you to customize the product icon theme, which controls icons used throughout the UI (like the activity bar icons). You can set this with:

{
  "workbench.productIconTheme": "icons-carbon"
}

Using Semantic Tokens

Modern VS Code supports semantic highlighting, which provides more accurate token classification than TextMate grammars. You can enable it and customize semantic token colors:

{
  "editor.semanticTokenColorCustomizations": {
    "enabled": true,
    "rules": {
      "property": {
        "foreground": "#7dcfff",
        "fontStyle": "italic"
      },
      "property.declaration": {
        "foreground": "#bb9af7"
      },
      "variable.declaration": {
        "foreground": "#e0af68"
      },
      "function": {
        "foreground": "#7aa2f7"
      },
      "type": {
        "foreground": "#2ac3de"
      }
    }
  }
}

Transparent Backgrounds

On some platforms, you can use semi-transparent colors for a glass-like effect. This works on macOS and some Linux setups:

{
  "workbench.colorCustomizations": {
    "editor.background": "#1e1e2ecc"
  }
}

The last two characters (cc) represent the alpha channel value in hexadecimal.

Best Practices for Theme Development

Ensure Sufficient Contrast

Accessibility should be a priority. The Web Content Accessibility Guidelines (WCAG) recommend a contrast ratio of at least 4.5:1 for normal text. Use tools like the WCAG Contrast Checker to verify your color combinations.

Use a Consistent Color Palette

Limit your palette to a manageable number of colors and assign them consistently. For example, always use the same color for functions across all languages. This helps developers build muscle memory and scan code faster.

Test Across Multiple Languages

Your theme should look good in all major programming languages. Test it with JavaScript, Python, Java, Go, Rust, HTML, CSS, and JSON files to ensure token colors are applied correctly.

Support Both Light and Dark Variants

If you are publishing a theme, consider offering both light and dark variants. Many users switch between them based on the time of day or their environment.

Use Semantic Highlighting

Enable semanticHighlighting in your theme to take advantage of more accurate token classification provided by language servers. This results in better syntax highlighting, especially for languages like TypeScript and Rust.

Document Your Theme

Include screenshots, installation instructions, and a color reference in your README. This helps users decide if your theme is right for them and makes it easier for them to customize further.

Popular Themes to Explore

If you are looking for inspiration or just want a great out-of-the-box experience, here are some widely loved themes:

Debugging Theme Issues

If your theme is not applying colors as expected, VS Code provides tools to help you debug. The most useful command is "Developer: Inspect Editor Tokens and Scopes". This opens an inspection overlay that shows you the exact scope of the token under your cursor, along with the theme rules that apply to it.

To use it:

  1. Press Ctrl+Shift+P to open the Command Palette.
  2. Type "Inspect Editor Tokens and Scopes" and press Enter.
  3. Hover over any token in your code to see its scope and applied colors.

This is invaluable when you are building a theme and need to know which TextMate scope or semantic token type corresponds to a specific piece of syntax.

Conclusion

VS Code's theming and customization system is remarkably powerful, offering everything from simple color tweaks to fully packaged theme extensions. Whether you just want to adjust a few colors in your favorite theme or build and publish your own, the tools and APIs are accessible and well-documented. By understanding how color themes, icon themes, token customizations, and font settings work together, you can create a coding environment that is not only visually pleasing but also optimized for focus, readability, and productivity. Start small with workbench.colorCustomizations, experiment with token colors, and when you are ready, scaffold a full theme extension to share your creation with the community.

— Ad —

Google AdSense will appear here after approval

← Back to all articles