Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

OpenCode Themes

OpenCode Themes

OpenCode supports multiple theme systems; you can choose built-in themes, auto-adapt to your terminal theme, or fully customize a theme for a consistent and comfortable terminal experience.

The simplest way is to type the /themes command in the TUI input box:


/themes

Then select your favorite theme in the pop-up window:


Terminal requirements

To ensure themes display the full color range correctly, your terminal must support true color (24-bit color)。


echo $COLORTERM

The output should be:


truecolor
或
24bit

export COLORTERM=truecolor

If the terminal doesn't support true color, the theme will fall back to 256 colors, which may cause color distortion.


Built-in themes

OpenCode has several built-in themes ready to use:

Theme name Description
system Auto-adapt to terminal theme
tokyonight Tokyonight style
everforest Everforest style
ayu Ayu dark theme
catppuccin Catppuccin theme
catppuccin-macchiato Catppuccin variant
gruvbox Gruvbox style
kanagawa Kanagawa style
nord Nord style
matrix Hacker style (green text on black background)
one-dark Atom One Dark

system theme (recommended)

system The theme automatically adapts to your terminal color scheme:

Suitable for:


Using themes

Method 1: Select a theme in the TUI


/themes

Method 2: Configure via a config file

tui.json


{
  "$schema": "https://opencode.ai/tui.json",
  "theme": "tokyonight"
}

Custom themes

OpenCode supports fully custom themes defined via JSON.

Theme load priority

Later-loaded themes override earlier ones.


creating themes

User-level themes:


mkdir -p ~/.config/opencode/themes
vim ~/.config/opencode/themes/my-theme.json

Project-level themes:


mkdir -p .opencode/themes
vim .opencode/themes/my-theme.json

Theme format description

The following formats are supported:


{
  "dark": "#000000",
  "light": "#ffffff"
}

"text": "none"

Complete example

my-theme.json


{
  "$schema": "https://opencode.ai/theme.json",
  "defs": {
    "bg": "#1e1e2e",
    "fg": "#cdd6f4",
    "primary": "#89b4fa",
    "accent": "#f38ba8",
    "success": "#a6e3a1",
    "warning": "#f9e2af"
  },
  "theme": {
    "primary": {
      "dark": "primary",
      "light": "#005f87"
    },
    "accent": {
      "dark": "accent",
      "light": "#d7005f"
    },
    "background": {
      "dark": "bg",
      "light": "#ffffff"
    },
    "text": {
      "dark": "fg",
      "light": "#000000"
    },
    "border": {
      "dark": "#313244",
      "light": "#cccccc"
    },
    "syntaxKeyword": {
      "dark": "primary",
      "light": "#0000ff"
    },
    "syntaxString": {
      "dark": "success",
      "light": "#008000"
    },
    "syntaxComment": {
      "dark": "#6c7086",
      "light": "#999999"
    }
  }
}

Summary

The OpenCode theme system has the following features:

If you pursue the ultimate experience, it is recommended: