Looking at the sample code, is this not enough to achieve it?
TextField textField = new TextField("Color"); textField.setValue("#FF00FF");Button button = new Button(“Set variable ‘–lumo-base-color’”, e ->
UI.getCurrent().getElement().getStyle()
.set(“–lumo-base-color”, textField.getValue()));