Yaml syntax for global constants/variable?

Having several themes (dark/light) in several theme files.
How do i use an include file in my theme file(s), with global variables like, g_banner-card-error-color: “blue”, and what is the correct syntax for the global file and for referencing the global variables in my theme files?

Please advise.

Example for one theme file:

global_theme_settings: !include global_theme_settings.yaml

my-light-mode:
  primary-background-color: "#e5e5ea"  
  secondary-background-color: rgba(255, 255, 255, 0.9)
  divider-color: "#8e8e93"  
  accent-color: rgba(255, 159, 9, 1)
  banner-card-error-color: g_banner-card-error-color

my-dark-mode:
  primary-background-color: "#e666ea"  
  secondary-background-color: rgba(255, 255, 255, 0)
  divider-color: "#888e93"  
  accent-color: rgba(255, 159, 9, 2)
  banner-card-error-color: g_banner-card-error-color

you’d only be able to use anchors but you can’t define an anchor using !include.

global_theme: &global_theme
  divider-color: "#8e8e93"  
  banner-card-error-color: g_banner-card-error-color
  
my-light-mode:
  <<: *global_theme
  primary-background-color: "#e5e5ea" 
  ...

my-dark-mode:
  <<: *global_theme
  primary-background-color: "#e666ea" 
  ...

Also, keep in mind that it will show up as a theme itself in your themes dropdown list. Second, it needs to be the first theme in your themes file. Lastly, you can’t use include at all for any other themes. Everything will need to be a flat single file.

1 Like