Structure of the JSON format for themes
This topic explains the structure of the JSON theme file. This JSON file contains mappings between different UI elements and their assigned colors, as well as other theme settings.
Themes are defined in JSON files and contain four blocks:
meta: metadata, such as the theme's name and type.
colors: colors for UI elements, such as buttons, headers, and backgrounds.
textAttributes (optional): text attributes used for syntax highlighting in the editor.
palette (optional): named colors that can be used in the
colors
andtextAttributes
blocks.
Supported color formats
The following color formats are supported, each offering specific ways to define colors with varying degrees of opacity:
#rrggbb
: this format represents colors using three pairs of hexadecimal digits, where each pair corresponds to the red, green, and blue components of the color. Each component can have a value ranging from 00 to FF, which corresponds to the intensity of that color component.Example:
#7f7f7f
Red:
7f
(127 in decimal, indicating a medium intensity of red).Green:
7f
(127 in decimal, indicating a medium intensity of green).Blue:
7f
(127 in decimal, indicating a medium intensity of blue).
This format does not include an alpha channel, meaning it is fully opaque.
#rrggbbaa
: this format is an extension of the#rrggbb
format, with an additional pair of hexadecimal digits to represent the alpha channel, which defines the opacity of the color.Example:
#7f7f7fff
.Red:
7f
(127 in decimal).Green:
7f
(127 in decimal).Blue:
7f
(127 in decimal).Alpha:
ff
(255 in decimal, indicating full opacity).
#RRGGBB
: similar to#rrggbb
, this format uses uppercase letters to denote the hexadecimal digits, which is purely stylistic and has no effect on the color itself.Example:
#7F7F7F
.#RRGGBBAA
: similar to#rrggbbaa
, this format uses uppercase letters to denote the hexadecimal digits, which is purely stylistic and has no effect on the color itself.Example:
#7F7F7FFF
.
meta
Defines mandatory theme properties.
Example:
colors
Specifies colors for UI elements like buttons, headers, and backgrounds.
Fallback rules: if a theme does not have a color key, it falls back to the corresponding key in the default Light
or Dark
theme, as defined by the theme.kind
key in meta
.
Example:
textAttributes
Defines text attributes used for syntax highlighting in the editor. This block is optional.
The following fallback rules are applied to this block:
If the
textAttributes
block is missing, the text attributes from the default Light or Dark theme are used (depending on thetheme.kind
key inmeta
).If the
textAttributes
block is present, text attributes will not fall back to the parent theme. If an attribute is not found, it tries to fall back on another attribute in the same theme by dropping the last segment. If there is no fallback, the default text color is used.
Fallback example: "problem.warning.weak"
-> "problem.warning"
-> "problem"
-> using default text color
Example:
Example:
palette
Defines named colors that can be used in the theme. This block is optional.
Example:
Example
Here is an example of a simple theme that changes colors in the code editor: