3

Is there a way to change dynamically the lumo primary colors:

html {
  --lumo-primary-text-color: hsl(214, 35%, 15%);
  --lumo-primary-color-50pct: rgba(140, 236, 0, 0.5);
  --lumo-primary-color-10pct: rgba(140, 236, 0, 0.1);
  --lumo-primary-color: #8CEC00;
  --lumo-primary-contrast-color: hsl(214, 35%, 15%);
}

Thanks in advance!

Best Regards, Thomas

ollitietavainen
  • 3,900
  • 13
  • 30
Thomas
  • 131
  • 7

1 Answers1

8

The CSS variables can be updated dynamically from Java like so

UI.getCurrent().getElement().getStyle().set("--lumo-primary-text-color", "hsl(214, 35%, 15%)")

This will update the variable's value for the whole UI. If you want to change the variable only for a specific component (and its children), then you can call getElement().getStyle().set() on that component only.

Tarek Oraby
  • 1,199
  • 6
  • 11