View Full Version : Gxt 2.x Component.setStyleAttribute

11 Jan 2012, 9:51 AM
Hi there.

I'm finally beginning some tries on the new Gxt 3.

In gxt 2, we could for example change a TextArea fontSize by calling the Component setStyleAttribute like this:

textArea.setStyleAttribute("fontSize", "12px");

How can we do the same in gxt 3?


Colin Alworth
11 Jan 2012, 7:42 PM
Quickest workaround I see at the moment is to call

component.getElement.getStyle().setFontSize(12, Unit.PX)

Other setters on Style should have most other details you may want to change. Other options are



component.getElement().getStyle().setProperty("font-size", "12px")

In general though, if styling something, the most efficient way is to set a id or classname, and use css - check out how CssResource can make this easy, and only add styles to the page when they are needed.