Docs

Documentation versions (currently viewingVaadin 25)
Documentation translations (currently viewingEnglish)

Horizontal Layout Styling

Styling API reference for the Horizontal Layout component.

Style Variants

Horizontal Layout supports the following style variants:

Variant Supported by

margin

Aura, Lumo

padding

Aura, Lumo

spacing

Aura, Lumo

wrap

Aura, Lumo

Spacing

Spacing is used to create space among components in the same layout. Spacing can help prevent misclicks and distinguish content areas.

Source code
HorizontalLayoutSpacing.java
horizontal-layout-spacing.tsx
horizontal-layout-spacing.ts

Five different spacing style variants are available:

Source code
horizontal-layout-spacing-variants.ts
Style Variant Usage Recommendation

spacing-xs

Extra-small space between items.

spacing-s

Small space between items.

spacing

Medium space between items.

spacing-l

Large space between items.

spacing-xl

Extra-large space between items.

Source code
Java
HorizontalLayout layout = new HorizontalLayout();
layout.setSpacing(false);
layout.getThemeList().add("spacing-xs");
Java
tsx
tsx
HTML
HTML

Alternatively, the spacing can be set to a custom value:

Source code
Java
HorizontalLayout layout = new HorizontalLayout();
layout.setSpacing(12, Unit.PIXELS);
Java
tsx
tsx
HTML
HTML

Padding

Padding is the space between the outer border and the content in a layout. Padding can help distinguish the content in a layout from its surrounding. Padding is applied using the padding style variant.

Source code
HorizontalLayoutPadding.java
horizontal-layout-padding.tsx
horizontal-layout-padding.ts

Margin

Use margin to create space around a layout.

Source code
HorizontalLayoutMargin.java
horizontal-layout-margin.tsx
horizontal-layout-margin.ts

Wrapping

By default, components in a layout either shrink or overflow when there isn’t enough horizontal space. Enable wrapping to allow components to flow onto a new line when space runs out, preventing overflow.

Source code
HorizontalLayoutWrapping.java
horizontal-layout-wrapping.tsx
horizontal-layout-wrapping.ts

Wrapping Horizontally Aligned Items

Wrapping may not behave as desired when combined with either of the two horizontal alignment methods. One common solution is group items that should wrap together into sub-layouts:

Source code
HorizontalLayoutSlotsWrapping.java
horizontal-layout-slots-wrapping.tsx
horizontal-layout-slots-wrapping.ts

Style Properties

The following style properties can be used in CSS stylesheets to customize the appearance of this component.

To apply values to these properties globally in your application UI, place them in a CSS block using the html {…​} selector. See Component Style Properties for more information on style properties.

Property Supported by

--vaadin-horizontal-layout-gap

Aura, Lumo

--vaadin-horizontal-layout-padding

Aura, Lumo

--vaadin-horizontal-layout-margin

Aura, Lumo

CSS Selectors

The following CSS selectors can be used in stylesheets to target the various parts and states of the component. See the Styling documentation for more details on how to style components.

Root element

vaadin-horizontal-layout