I can show what I have learned while working on my game, Depthris.
I first define the style with a custom name and give some attributes which will be common to many UI elements.
Styles styles = GuiGlobals.getInstance().getStyles();
Attributes attributes = styles.getSelector("my_style");
attributes.set("font", assetManager.loadFont("Fonts/myFont.fnt"));
attributes.set("color", ColorRGBA.White);
attributes.set("fontSize", 14)
I then I create attributes for a header Label that I want. It inherits the common attributes defined above but I can also overwrite them if needed, like the font size in this case
attributes = styles.getSelector("header", "my_style");
attributes.set("textHAlignment", HAlignment.Center);
attributes.set("textVAlignment", VAlignment.Center);
attributes.set("fontSize", 23);
......
// Now to use it I declare a Label with the style and id I created:
Container container = new Container();
container.setPreferredSize(new Vector3f(400, 100,0));
guiNode.attachChild(container)
Label title = new Label("Hello World!!!", new ElementId("header"), "my_style");
container.addChild(title);
If you want to declare a style for all labels you use Label.ELEMENT_ID like this example
attributes = styles.getSelector(Label.ELEMENT_ID, "my_style");
attributes.set("textHAlignment", HAlignment.Right);
attributes.set("fontSize", 23);
....
// In this case you don't need to use the ElementID parameter since it will use the default one
Label label= new Label("Have a nice day! ", "my_style");
container.addChild(label);
You can declare styles for any Lemur UI element you need. you don’t need to use the default glass one if you don’t want to. You can use some elements with the default glass style and some of your custom one without issues.
I learned most of it reading through the docs and some trial en error until I got it . I hope it helps