How It Works
Themes in Tempest follow a token-to-CSS-variable naming pattern. A theme file defines semantic color tokens likebg.editor or fg.default, which are automatically converted to CSS variables like --tempest-bg-editor and --tempest-fg-default.
Token to CSS Variable Conversion
The system converts dot-notation tokens to kebab-case CSS variables:Theme Structure
Each theme is a JSON file with the following structure:Required Fields
- name: A human-readable theme name (e.g., “Tempest Dark”, “Tempest Light”)
- type: Either “dark” or “light”, used for semantics and theming context
- colors: An object where keys are color tokens and values are hex color values
Built-in Themes
Tempest includes two built-in themes:Tempest Dark
Located atsrc/themes/origin-dark/theme.json
Dark theme optimized for low-light environments with high contrast and vibrant accent colors.
Tempest Light
Located atsrc/themes/origin-light/theme.json
Light theme designed for bright environments with muted accents and light backgrounds.
Color Token Categories
Themes organize colors into semantic categories:Background Colors (bg.*)
bg.base: Primary background colorbg.editor: Editor/content area backgroundbg.sidebar: Sidebar backgroundbg.panel: Panel backgroundbg.titlebar: Title bar backgroundbg.hover: Hover state backgroundbg.active: Active/selected state backgroundbg.input: Input field backgroundbg.selection: Text selection backgroundbg.selection-focused: Focused text selection background
Foreground Colors (fg.*)
fg.default: Default text colorfg.muted: Muted or secondary textfg.subtle: Very subtle/disabled text
Border Colors (border.*)
border.default: Default border colorborder.subtle: Subtle/secondary border color
Accent Colors (accent.*)
Seven accent colors for UI elements and highlights:
accent.blueaccent.pinkaccent.greenaccent.yellowaccent.purpleaccent.cyanaccent.red
Syntax Highlighting (syntax.*)
Colors for code syntax highlighting:
syntax.comment: Commentssyntax.keyword: Keywordssyntax.string: Stringssyntax.function: Function namessyntax.variable: Variablessyntax.constant: Constantssyntax.type: Type annotationssyntax.operator: Operatorssyntax.attribute: Attributes
Git Status (git.*)
Colors for git status indicators:
git.added: Added filesgit.modified: Modified filesgit.deleted: Deleted filesgit.conflict: Merge conflictsgit.ignored: Ignored filesgit.untracked: Untracked files
Island UI (island.*)
Colors for collapsible/expandable UI elements:
island.bg-closed: Background when closedisland.border-closed: Border when closedisland.bg-open: Background when openisland.border-open: Border when open
Tooltip Colors (tooltip.*)
tooltip.bg: Tooltip backgroundtooltip.fg: Tooltip text color
Semantic Colors (semantic.*)
Standard status/message colors:
semantic.error: Error statesemantic.warning: Warning statesemantic.info: Info statesemantic.success: Success state
Terminal Colors (terminal.*)
16-color terminal palette:
terminal.fg: Default foregroundterminal.selection: Selection backgroundterminal.black,terminal.red,terminal.green,terminal.yellow,terminal.blue,terminal.purple,terminal.cyan,terminal.white: Standard colorsterminal.brightBlack,terminal.brightRed,terminal.brightGreen,terminal.brightYellow,terminal.brightBlue,terminal.brightPurple,terminal.brightCyan,terminal.brightWhite: Bright variants
Using Themes in Components
Components use CSS variables directly in stylesheets:Theme Management
React Context API
The theme system uses React Context (ThemeProvider) to manage theme state and provide theme switching capabilities throughout the app.
Available Context Functions
- theme: The currently active theme object
- themes: Array of all built-in themes
- setTheme(theme): Switch to a different theme
- loadThemeFromJson(json): Load a custom theme from a JSON string
Persistence
The currently selected theme is persisted to localStorage under the keytempest-theme. On app startup, the system:
- Checks if a theme is saved in localStorage
- Validates the saved theme name (handles legacy “Origin” theme name migration)
- Falls back to system preference (dark or light mode)
- Falls back to the first available built-in theme if no match is found
Legacy Theme Names
For backwards compatibility, the system automatically migrates old theme names:- “Origin Dark” → “Tempest Dark”
- “Origin Light” → “Tempest Light”
Application Flow
- Initialization:
main.tsxwraps the app withThemeProvider - Theme Resolution: On startup,
resolveDefaultTheme()determines which theme to use - CSS Application:
applyTheme()sets all CSS variables on the document root and adds adata-themeattribute - Component Rendering: React components access variables via
var(--tempest-*) - Theme Switching: Users can change themes via
setTheme(), which updates state, applies CSS, and persists to localStorage
Creating Custom Themes
Custom themes can be loaded programmatically usingloadThemeFromJson():
name and colors properties to be valid.