egui-thematic
A theme editor and configuration system for egui applications with live preview, preset management, random theme generation, and persistence.
Features
-
Complete Theme Configuration: Full control over all 73 egui visual properties
- 8 core color palette entries (background, surface, primary, text, text weak, widget fill/hover/active)
- 3 global appearance controls (corner radius, border width, window shadow)
- 5 widget states × 8 properties each (noninteractive, inactive, hovered, active, open)
- Additional UI controls (text cursor, resize corners, button frames, etc.)
-
Two-Level Interface:
- Simple Mode: 8 colors + 3 sliders for quick theming (covers 80% of use cases)
- Advanced Mode: Collapsible sections for fine-grained per-widget-state control
-
Live Preview Window: Separate window shows changes instantly with Apply/Revert buttons
- See all changes before committing
- Keyboard shortcuts: Ctrl+Enter to apply, Escape to revert
- Fully interactive preview with all widget types
-
Smart Global Controls: Automatically detect when widget states have mixed values
- Disabled when states differ to prevent accidental overwrites
- Shows "(mixed)" indicator for clarity
-
9 Built-in Presets: Dark, Light, Dracula, Nord, Gruvbox, Solarized (Dark/Light), Monokai, One Dark, Tokyo Night, Catppuccin Mocha
-
Random Theme Generation: Generate completely random themes with a single click for exploration and inspiration
-
Code Export: Export themes as JSON or Rust code for easy integration
-
Persistence: Save and load themes to/from JSON files for easy sharing and reuse
Installation
Add this to your Cargo.toml:
[]
= "0.1.1" # supports egui 0.33.0
Usage
Quickstart
Add egui-thematic to your egui application, here's an example using the nightshade game engine:
Cargo.toml:
[]
= "0.6.7"
= "0.1.1"
main.rs:
use ;
use *;
Working with Themes
Using Presets
use ThemeConfig;
// Use built-in presets
let dark_theme = dark_preset;
let light_theme = light_preset;
// Apply to egui context
ctx.set_visuals;
Saving and Loading Themes
use ThemeConfig;
use Path;
// Save theme to file
let theme = dark_preset;
theme.save_to_file?;
// Load theme from file
let loaded_theme = load_from_file?;
Generating Random Themes
use ThemeConfig;
// Generate a completely random theme
let random_theme = randomize;
// Apply it
ctx.set_visuals;
The randomize feature can be used for:
- Exploring different color combinations
- Finding inspiration for custom themes
- Testing your UI with extreme color variations
Demo Application
A demo application is included that showcases the features of egui-thematic.
Running the Demo
Using just:
Or directly with cargo:
The demo includes:
- Theme editor with all features
- Sample UI elements showing how the theme affects different widgets
- Preset buttons (Dark, Light, Randomize)
- Instructions and examples
Development
Prerequisites
- Rust 1.90.0 or later
- just (optional, for convenience commands)
Available Commands
Using justfile for convenience:
just run- Run the demo application in release modejust build- Build the crate in release modejust check- Run cargo check and format verificationjust format- Format all code with rustfmtjust fix- Run clippy with auto-fixesjust lint- Run clippy with warnings as errorsjust test- Run all testsjust versions- Display tool versions
Theme Configuration
The ThemeConfig struct provides complete control over all 73 egui visual properties:
All overrides are optional - when None, egui's default values for the selected mode (dark/light) are used. This allows for:
- Minimal configuration (just override what you need)
- Full control (override all 73 properties for complete customization)
- Mix and match (use defaults for most things, customize specific details)
License
Licensed under the MIT License. See LICENSE for details.