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

Viewed 173

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+)

1 Answers

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

Related