Horizontal Layout Styling
Style Variants
Horizontal Layout supports the following style variants:
| Variant | Supported by |
|---|---|
| Aura, Lumo |
| Aura, Lumo |
| Aura, Lumo |
| 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 |
|---|---|
| Extra-small space between items. |
| Small space between items. |
| Medium space between items. |
| Large space between items. |
| Extra-large space between items. |
Source code
Java
HorizontalLayout layout = new HorizontalLayout();
layout.setSpacing(false);
layout.getThemeList().add("spacing-xs");Java
tsx
<HorizontalLayout
theme="spacing-xs padding">
</HorizontalLayout>tsx
HTML
<vaadin-horizontal-layout
theme="spacing-xs padding">
</vaadin-horizontal-layout>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
<HorizontalLayout style={{ gap: '12px' }}>
</HorizontalLayout>tsx
HTML
<vaadin-horizontal-layout style="gap: 12px">
</vaadin-horizontal-layout>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 |
|---|---|
| Aura, Lumo |
| Aura, Lumo |
| 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