Built-in Themes
CustomTkinter comes with four built-in color themes:- blue (default): Professional blue accent colors
- green: Fresh green accent colors
- dark-blue: Deep blue accent colors
- sweetkind: Custom theme with unique color palette
Setting a Theme
Useset_default_color_theme() to change the active theme:
Complete Example
Theme File Structure
Themes are stored as JSON files in theassets/themes/ directory. Here’s what a theme file looks like:
Color arrays like
["#2CC985", "#2FA572"] contain two values: [light_mode_color, dark_mode_color].Creating Custom Themes
You can create your own theme by providing a path to a custom JSON file:Custom Theme Example
Create a file calledmy_theme.json:
Themed Widget Properties
Each widget type can have the following theme properties:Common Properties
Common Properties
fg_color: Foreground/background color (array for light/dark)text_color: Text colorborder_color: Border colorcorner_radius: Corner radius in pixelsborder_width: Border width in pixelshover_color: Color when hovering (for interactive widgets)
Widget-Specific Properties
Widget-Specific Properties
CTkButton, CTkOptionMenu
text_color_disabled: Text color when disabled
placeholder_text_color: Placeholder text color
progress_color: Color of the progress/active portionbutton_color: Color of the draggable button/knobbutton_hover_color: Button color on hover
checkmark_color: Color of the checkmark/indicator
Platform-Specific Themes
Themes can specify different values for different operating systems:CustomTkinter automatically selects the appropriate platform-specific values when loading the theme.
Theme Manager Internals
How Theme Loading Works
How Theme Loading Works
The
ThemeManager class handles theme loading:- Built-in Detection: Checks if the theme name matches a built-in theme (
blue,green,dark-blue,sweetkind) - File Loading: Loads the JSON file from the built-in directory or custom path
- Platform Filtering: Extracts platform-specific values for the current OS
- Name Normalization: Fixes inconsistencies (e.g.,
CTkCheckbox→CTkCheckBox) - Storage: Stores the theme data in
ThemeManager.themedictionary
- Blue Theme
- Green Theme
- Dark Blue Theme
Professional blue accent colors (
#3B8ED0 in light, #1F6AA5 in dark). Great for business and productivity applications.Best Practices
- Set theme early: Always call
set_default_color_theme()before creating any windows or widgets - Test both modes: Verify your theme looks good in both light and dark appearance modes
- Use semantic colors: Name your colors based on purpose (primary, secondary, accent) rather than specific hues
- Provide defaults: Include all widget types in your custom theme to ensure consistency
- Consider accessibility: Ensure sufficient contrast between text and background colors
Related Functions
set_default_color_theme(color_string)- Set the color themeset_appearance_mode()- Set light/dark mode (see Appearance Modes)