Skip to main content

Building Theme Extensions

Theme extensions allow you to create custom color schemes and icon themes for Glass. Themes can be distributed as standalone extensions or bundled with other extension features.

Theme Types

Glass supports two types of themes:
  • Color Themes - Define syntax highlighting, UI colors, and editor appearance
  • Icon Themes - Provide custom file and folder icons for the file tree

Creating a Color Theme

1
Create the extension structure
2
Create your extension directory with a themes/ folder:
3
my-theme-extension/
  extension.toml
  themes/
    my-theme.json
4
Theme extension IDs should be suffixed with -theme (e.g., monokai-theme).
5
Define extension.toml
6
Create a minimal extension.toml for a theme-only extension:
7
id = "my-theme"
name = "My Theme"
version = "0.1.0"
schema_version = 1
authors = ["Your Name <[email protected]>"]
description = "A beautiful color theme for Glass"
repository = "https://github.com/your-name/my-theme"
8
Create the theme file
9
Create themes/my-theme.json with your theme definition:
10
{
  "name": "My Theme",
  "author": "Your Name",
  "themes": [
    {
      "name": "My Theme Dark",
      "appearance": "dark",
      "style": {
        "background": "#1e1e1e",
        "foreground": "#d4d4d4",
        "cursor": "#ffffff",
        "selection": "#264f78",
        "comment": "#6a9955",
        "string": "#ce9178",
        "number": "#b5cea8",
        "keyword": "#569cd6",
        "function": "#dcdcaa",
        "type": "#4ec9b0",
        "variable": "#9cdcfe",
        "operator": "#d4d4d4"
      }
    },
    {
      "name": "My Theme Light",
      "appearance": "light",
      "style": {
        "background": "#ffffff",
        "foreground": "#000000",
        "cursor": "#000000",
        "selection": "#add6ff",
        "comment": "#008000",
        "string": "#a31515",
        "number": "#098658",
        "keyword": "#0000ff",
        "function": "#795e26",
        "type": "#267f99",
        "variable": "#001080",
        "operator": "#000000"
      }
    }
  ]
}

Theme File Structure

The theme JSON file contains:
  • name - Theme family name
  • author - Theme creator name
  • themes - Array of theme variants (dark/light)
Each theme variant includes:
  • name - Variant name (shown in the theme picker)
  • appearance - Either "dark" or "light"
  • style - Color definitions for syntax and UI elements

Syntax Highlighting Colors

These colors map to Tree-sitter captures:
PropertyDescriptionExample
commentComments#6a9955
comment.docDocumentation comments#6a9955
stringString literals#ce9178
string.escapeEscape sequences#d7ba7d
string.regexRegular expressions#d16969
numberNumeric literals#b5cea8
booleanBoolean values#569cd6
keywordLanguage keywords#569cd6
operatorOperators#d4d4d4
functionFunction names#dcdcaa
typeType names#4ec9b0
type.builtinBuilt-in types#569cd6
variableVariables#9cdcfe
variable.specialSpecial variables#9cdcfe
variable.parameterFunction parameters#9cdcfe
propertyObject properties#9cdcfe
constructorConstructors#4ec9b0
constantConstants#4fc1ff
constant.builtinBuilt-in constants#569cd6
tagHTML/XML tags#569cd6
attributeHTML/XML attributes#9cdcfe
labelLabels#c8c8c8
punctuationPunctuation#d4d4d4
punctuation.bracketBrackets#ffd700
punctuation.delimiterDelimiters#d4d4d4

UI Colors

Define colors for the editor interface:
{
  "style": {
    "background": "#1e1e1e",
    "foreground": "#d4d4d4",
    "cursor": "#ffffff",
    "selection": "#264f78",
    "line_highlight": "#2a2a2a",
    "match_highlight": "#515c6a",
    "search_match": "#4b3f2f",
    "active_line_number": "#c6c6c6",
    "line_number": "#858585",
    "gutter_background": "#1e1e1e",
    "border": "#454545",
    "scrollbar": "#424242",
    "panel_background": "#252526",
    "tab_active_background": "#1e1e1e",
    "tab_inactive_background": "#2d2d2d",
    "status_bar_background": "#007acc",
    "title_bar_background": "#3c3c3c"
  }
}

Programmatic Theme Loading

For advanced theme extensions that need to generate themes programmatically, you can use Rust code:
1
Add dependencies
2
Update your Cargo.toml:
3
[dependencies]
zed_extension_api = "0.7.0"
4
Implement the extension
5
Create src/lib.rs:
6
use zed_extension_api as zed;

struct MyThemeExtension;

impl zed::Extension for MyThemeExtension {
    fn new() -> Self {
        Self
    }
}

zed::register_extension!(MyThemeExtension);
For most theme extensions, static JSON files in the themes/ directory are sufficient. Programmatic loading is only needed for themes generated at runtime.

Creating Icon Themes

Icon themes provide custom icons for files and folders in the project panel.
1
Create the icon theme structure
2
my-icon-theme/
  extension.toml
  icon-themes/
    my-icons.json
    icons/
      file.svg
      folder.svg
      folder-open.svg
      javascript.svg
      rust.svg
3
Define the icon theme
4
Create icon-themes/my-icons.json:
5
{
  "name": "My Icons",
  "themes": [
    {
      "name": "My Icons",
      "icons": {
        "file": "icons/file.svg",
        "folder": "icons/folder.svg",
        "folder_open": "icons/folder-open.svg",
        "extensions": {
          "js": "icons/javascript.svg",
          "ts": "icons/typescript.svg",
          "rs": "icons/rust.svg",
          "py": "icons/python.svg"
        },
        "filenames": {
          "Cargo.toml": "icons/cargo.svg",
          "package.json": "icons/npm.svg"
        }
      }
    }
  ]
}
6
Add SVG icons
7
Create SVG files in the icons/ directory. Icons should be simple, monochromatic, and sized appropriately (typically 16x16 or 24x24).

Testing Your Theme

1
Install as dev extension
2
Press Cmd+Shift+P and run Extensions: Install Dev Extension, then select your theme directory.
3
Select your theme
4
Open the theme picker:
5
  • Press Cmd+K, Cmd+T (macOS)
  • Or Ctrl+K, Ctrl+T (Linux/Windows)
  • 6
    Your theme should appear in the list.
    7
    Test in different contexts
    8
    Verify your theme works well with:
    9
  • Different file types (Rust, JavaScript, Markdown, etc.)
  • Dark and light system themes
  • Different UI panels (terminal, assistant, file tree)
  • Theme Best Practices

    Accessibility Considerations
    • Ensure sufficient contrast between foreground and background colors (WCAG AA: 4.5:1 for normal text)
    • Test with colorblindness simulators
    • Provide both dark and light variants
    Design Tips
    • Use a limited color palette (6-8 colors) for consistency
    • Reserve bright colors for important elements
    • Keep syntax highlighting subtle to reduce eye strain
    • Test with real code files, not just examples

    Example: Complete Theme Extension

    Here’s a complete minimal theme extension:
    id = "sunset-theme"
    name = "Sunset Theme"
    version = "0.1.0"
    schema_version = 1
    authors = ["Your Name <[email protected]>"]
    description = "Warm sunset colors for your code"
    repository = "https://github.com/you/sunset-theme"
    

    Publishing Your Theme

    To share your theme with the Glass community, submit it to the extensions registry. See the Managing Extensions guide for more information.

    See Also

    Build docs developers (and LLMs) love