yourButton.getElement().setAttribute(“theme”, " string1 string2");
string1 can be : error(red), success(green), contrast(black) or nothing (blue)
string2 can be : primary, secondary or tertiary
Useful notice: if you want to have a button with an Icon only, use “icon string1 string2”
An important detail about the component.getStyle() method is that it’s actually only a short form of component.getElement().getStyle(). So your approach was not too far off since you tried to make changes on the element too