Skip to main content

Color and Themes

Color​

All colors of the widgets can be customised, the appropriate arguments can be found in the documentation of the specific widgets. Note that bg_color is only the color behind the widget if it has rounded corners. The main color of a widget is called fg_color:

CTkButton color attributes explained

The colors can either be set to a single color name ("red"), a single hex color string ("#FF0000") or a tuple color for a light mode color and dark mode color (("red", "darkred")). The current color will then be picked by the widget automatically according to the current appearance mode. So by using the tuple color, the widgets can have different colors in light and dark appearance mode. If you use a single color then this color will be used for both light and dark appearance mode.

Example:

button = customtkinter.CTkButton(root_tk, fg_color="red") # single color name
button = customtkinter.CTkButton(root_tk, fg_color="#FF0000") # single hex string
button = customtkinter.CTkButton(root_tk, fg_color=("#DB3E39", "#821D1A")) # tuple color

Themes​

By default all colors are set by the color theme. There are four built-in themes: "blue" (standard), "dark-blue", "green" and "gold". The gold theme is new in 6.0. All themes provide tuple colors for a light and dark appearance mode.

Set the theme at the beginning of your program, before you create any widgets:

customtkinter.set_default_color_theme("dark-blue") # Themes: "blue" (standard), "green", "dark-blue", "gold"

The four built-in themes blue, dark-blue, green and gold

The Showroom lets you switch between all themes, appearance modes and scaling levels in one window.

Custom Themes​

A theme is described by a .json file like this: dark-blue.json. You can also create your own theme, so that you don't have to set the styling for every widget manually. Just copy the .json file above and change the values. Then you can load the new theme by passing the path to your .json file to the .set_default_color_theme method:

customtkinter.set_default_color_theme("path/to/your/custom_theme.json")

A theme file contains one section per widget (CTk, CTkToplevel, CTkFrame, CTkButton, CTkLabel, …) with the default values for its arguments, like fg_color, text_color, corner_radius or border_width. Every color is given as a list of two values for light and dark mode, for example ["#3B8ED0", "#1F6AA5"]. The section CTkFont sets the default font family, size and weight for each operating system.

Since 6.0 the CTkLabel section can also contain border_width and border_color. Older theme files without these values keep working.

The tutorial Colors and Custom Themes shows how to create a theme file and switch themes while the app is running.