Stephane Grenier
Stephane Grenier

Reputation: 15925

How do I adjust the spacing between buttons in a Layout such as the HorizontalLayout in Vaadin Flow?

For example how do I reduce the spacing between the buttons in the following HorizontalLayout:

enter image description here

The code:

HorizontalLayout horizontalLayout = new HorizontalLayout();
horizontalLayout.setWidthFull();
horizontalLayout.setJustifyContentMode(JustifyContentMode.END);
buttons.forEach(button -> {
    horizontalLayout.add(button);
    horizontalLayout.addThemeVariants(ButtonVariant.LUMO_SMALL);
});

** This is for Vaadin Flow (Vaadin 14+)

Upvotes: 3

Views: 657

Answers (1)

Hawk
Hawk

Reputation: 2142

instead of the default "spacing" theme on the HL, use "spacing-s" or "spacing-xs"

var hl = new HorizontalLayout();
hl.setSpacing(false);
hl.getThemeList().add("spacing-s");

see JavaDoc

Upvotes: 7

Related Questions