|
|
8 months ago | |
|---|---|---|
| .. | ||
| themes | 8 months ago | |
| README.md | 8 months ago | |
| loader.go | 8 months ago | |
| loader_test.go | 8 months ago | |
| manager.go | 8 months ago | |
| theme.go | 8 months ago | |
OpenCode supports a flexible JSON-based theme system that allows users to create and customize themes easily.
Themes are loaded from multiple directories in the following order (later directories override earlier ones):
~/.config/opencode/themes/*.json (or $XDG_CONFIG_HOME/opencode/themes/*.json)<project-root>/.opencode/themes/*.json./.opencode/themes/*.jsonIf multiple directories contain a theme with the same name, the theme from the directory with higher priority will be used.
To create a custom theme, create a JSON file in one of the theme directories:
# For user-wide themes
mkdir -p ~/.config/opencode/themes
vim ~/.config/opencode/themes/my-theme.json
# For project-specific themes
mkdir -p .opencode/themes
vim .opencode/themes/my-theme.json
Themes use a flexible JSON format with support for:
"#ffffff"3 (0-255)"primary" or custom definitions{"dark": "#000", "light": "#fff"}{
"$schema": "../theme.schema.json",
"defs": {
"brandColor": "#ff6600",
"darkBg": "#1a1a1a",
"lightBg": "#ffffff"
},
"theme": {
"primary": "brandColor",
"secondary": {
"dark": "#0066ff",
"light": "#0044cc"
},
"accent": 208,
"text": {
"dark": "#ffffff",
"light": "#000000"
},
"background": {
"dark": "darkBg",
"light": "lightBg"
},
"border": {
"dark": 8,
"light": 7
},
"borderActive": "primary"
}
}
The defs section (optional) allows you to define reusable colors that can be referenced in the theme.
At minimum, a theme must define:
primarysecondaryaccenttexttextMutedbackgroundprimary, secondary, accenterror, warning, success, infotext, textMutedbackground, backgroundPanel, backgroundElementborder, borderActive, borderSubtlediffAdded, diffRemoved, diffContext, etc.markdownHeading, markdownLink, markdownCode, etc.syntaxKeyword, syntaxFunction, syntaxString, etc.See the JSON schema file for a complete list of available colors.
OpenCode comes with several built-in themes:
opencode - Default OpenCode themetokyonight - Tokyo Night themeeverforest - Everforest themeayu - Ayu dark themeTo use a theme, set it in your OpenCode configuration or select it from the theme dialog in the TUI.