vaadinvaadin12

Controlling spacing size in Vaadin 12/13 horizontal/vertical layouts


In Vaadin 12/13, we can turn on/off spacing in a veritcal/horizontal layout by calling setSpacing(...). But, what if we want spacing but a much smaller amount of spacing? How can we (via Java) set the spacing to a much smaller amount? (For margins and padding, I figured out the css -- it's a straightfoward this.getStyle().set("margin", "2rem") or this.getStyle().set("padding", "2rem") etc., but I couldn't figure it out for spacing. Also, is it "dangerous" if we also run setSpacing(true) (if we do it before any code we write to explicilty set a different value for the spacing?)


Solution

  • Probably the easiest way to customize the spacing is to set using the predefined custom properties as described in this document. As you see, the "padding" is the right way to do.

    https://cdn.vaadin.com/vaadin-lumo-styles/1.4.1/demo/sizing-and-spacing.html#spacing