@@ -19,9 +19,9 @@ function Example() {
{/* tag::snippet[] */}
{/* end::snippet[] */}
diff --git a/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-horizontal-alignment.tsx b/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-horizontal-alignment.tsx
index 08a196cdf1..5eeed48dc6 100644
--- a/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-horizontal-alignment.tsx
+++ b/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-horizontal-alignment.tsx
@@ -1,15 +1,15 @@
import { reactExample } from 'Frontend/demo/react-example'; // hidden-source-line
import React from 'react';
-import { Button, VerticalLayout } from '@vaadin/react-components';
+import { VerticalLayout } from '@vaadin/react-components';
import layoutExampleStyle from './layoutExampleStyle'; // hidden-source-line
function Example() {
return (
// tag::snippet[]
// end::snippet[]
);
diff --git a/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-individual-alignment.tsx b/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-individual-alignment.tsx
index a4fc7461b8..23872caee9 100644
--- a/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-individual-alignment.tsx
+++ b/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-individual-alignment.tsx
@@ -1,17 +1,19 @@
import { reactExample } from 'Frontend/demo/react-example'; // hidden-source-line
import React from 'react';
-import { Button, VerticalLayout } from '@vaadin/react-components';
+import { VerticalLayout } from '@vaadin/react-components';
import layoutExampleStyle from './layoutExampleStyle'; // hidden-source-line
function Example() {
return (
// tag::snippet[]
// end::snippet[]
);
diff --git a/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-vertical-alignment.tsx b/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-vertical-alignment.tsx
index cdb7c51c28..a6dff89b1e 100644
--- a/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-vertical-alignment.tsx
+++ b/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-vertical-alignment.tsx
@@ -1,6 +1,6 @@
import { reactExample } from 'Frontend/demo/react-example'; // hidden-source-line
import React from 'react';
-import { Button, VerticalLayout } from '@vaadin/react-components';
+import { VerticalLayout } from '@vaadin/react-components';
import layoutExampleStyle from './layoutExampleStyle'; // hidden-source-line
function Example() {
@@ -11,9 +11,9 @@ function Example() {
className="height-4xl"
style={{ justifyContent: 'center' }}
>
-
// end::snippet[]
);
diff --git a/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-wrapping.tsx b/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-wrapping.tsx
index 48ff36080a..78f002f02b 100644
--- a/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-wrapping.tsx
+++ b/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout-wrapping.tsx
@@ -1,5 +1,5 @@
import { reactExample } from 'Frontend/demo/react-example'; // hidden-source-line
-import { Button, HorizontalLayout, VerticalLayout } from '@vaadin/react-components';
+import { HorizontalLayout, VerticalLayout } from '@vaadin/react-components';
import layoutExampleStyle from './layoutExampleStyle'; // hidden-source-line
function Example() {
@@ -8,10 +8,10 @@ function Example() {
@@ -22,10 +22,10 @@ function Example() {
style={{ alignItems: 'stretch', height: '200px' }}
>
{/* end::snippet[] */}
-
-
-
-
+
Item 1
+
Item 2
+
Item 3
+
Item 4
{/* tag::snippet[] */}
{/* end::snippet[] */}
diff --git a/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout.tsx b/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout.tsx
index 0f206d5556..89400d2e15 100644
--- a/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout.tsx
+++ b/frontend/demo/component/basiclayouts/react/basic-layouts-vertical-layout.tsx
@@ -1,15 +1,15 @@
import { reactExample } from 'Frontend/demo/react-example'; // hidden-source-line
import React from 'react';
-import { Button, VerticalLayout } from '@vaadin/react-components';
+import { VerticalLayout } from '@vaadin/react-components';
import layoutExampleStyle from './layoutExampleStyle'; // hidden-source-line
function Example() {
return (
// tag::snippet[]
-
-
-
+ Item 1
+ Item 2
+ Item 3
// end::snippet[]
);
diff --git a/frontend/demo/component/basiclayouts/react/layoutExampleStyle.ts b/frontend/demo/component/basiclayouts/react/layoutExampleStyle.ts
index c378bb8af8..81f2c01c6a 100644
--- a/frontend/demo/component/basiclayouts/react/layoutExampleStyle.ts
+++ b/frontend/demo/component/basiclayouts/react/layoutExampleStyle.ts
@@ -21,6 +21,14 @@ const layoutExampleStyles = css`
border: 1px solid var(--lumo-success-color);
border-radius: var(--lumo-border-radius-l);
}
+
+ .example-item {
+ background: var(--lumo-primary-color);
+ color: var(--lumo-primary-contrast-color);
+ border-radius: var(--lumo-border-radius-m);
+ padding: var(--lumo-space-s) var(--lumo-space-l);
+ white-space: nowrap;
+ }
`;
export default layoutExampleStyles;
diff --git a/frontend/themes/docs/basic-layouts.css b/frontend/themes/docs/basic-layouts.css
index 28bd2e4e67..4f27e2e076 100644
--- a/frontend/themes/docs/basic-layouts.css
+++ b/frontend/themes/docs/basic-layouts.css
@@ -24,4 +24,13 @@
:host(.basic-layouts-example) .container {
border: 1px solid var(--lumo-success-color);
border-radius: var(--lumo-border-radius-l);
-}
\ No newline at end of file
+}
+
+.basic-layouts-example .example-item,
+:host(.basic-layouts-example) .example-item {
+ background: var(--lumo-primary-color);
+ color: var(--lumo-primary-contrast-color);
+ border-radius: var(--lumo-border-radius-m);
+ padding: var(--lumo-space-s) var(--lumo-space-l);
+ white-space: nowrap;
+}
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsExpandingItems.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsExpandingItems.java
index 4fcfa0d302..7887ceab7a 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsExpandingItems.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsExpandingItems.java
@@ -2,7 +2,6 @@
import com.vaadin.demo.DemoExporter; // hidden-source-line
import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.router.Route;
@@ -11,16 +10,23 @@ public class BasicLayoutsExpandingItems extends Div {
public BasicLayoutsExpandingItems() {
// tag::snippet[]
- Button button1 = new Button("Button 1");
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
HorizontalLayout layout = new HorizontalLayout();
- layout.setFlexGrow(1, button1);
+ layout.setFlexGrow(1, item1);
// end::snippet[]
layout.setPadding(true);
- layout.add(button1);
- layout.add(new Button("Button 2"));
- layout.add(new Button("Button 3"));
+ layout.add(item1);
+
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+ layout.add(item2);
+
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+ layout.add(item3);
+
this.add(layout);
-
this.setClassName("basic-layouts-example");
}
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayout.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayout.java
index 69962a38d0..f3475d9385 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayout.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayout.java
@@ -2,7 +2,6 @@
import com.vaadin.demo.DemoExporter; // hidden-source-line
import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.router.Route;
@@ -12,13 +11,20 @@ public BasicLayoutsHorizontalLayout() {
// tag::snippet[]
HorizontalLayout layout = new HorizontalLayout();
layout.setPadding(true);
- layout.add(new Button("Button 1"));
- layout.add(new Button("Button 2"));
- layout.add(new Button("Button 3"));
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+
+ layout.add(item1, item2, item3);
// end::snippet[]
this.setClassName("basic-layouts-example");
-
this.add(layout);
}
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutHorizontalAlignment.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutHorizontalAlignment.java
index e6b33477cc..9f3dd7e80d 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutHorizontalAlignment.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutHorizontalAlignment.java
@@ -2,7 +2,6 @@
import com.vaadin.demo.DemoExporter; // hidden-source-line
import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.router.Route;
@@ -15,9 +14,17 @@ public BasicLayoutsHorizontalLayoutHorizontalAlignment() {
HorizontalLayout layout = new HorizontalLayout();
layout.setPadding(true);
layout.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER);
- layout.add(new Button("Button 1"));
- layout.add(new Button("Button 2"));
- layout.add(new Button("Button 3"));
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+
+ layout.add(item1, item2, item3);
// end::layout[]
this.setClassName("basic-layouts-example");
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutIndividualAlignment.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutIndividualAlignment.java
index ef4be81cc4..ce495461f5 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutIndividualAlignment.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutIndividualAlignment.java
@@ -4,7 +4,6 @@
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
-import com.vaadin.flow.component.textfield.TextArea;
import com.vaadin.flow.router.Route;
@Route("basic-layouts/horizontal-layout-individual-alignment")
@@ -12,16 +11,23 @@ public class BasicLayoutsHorizontalLayoutIndividualAlignment extends Div {
public BasicLayoutsHorizontalLayoutIndividualAlignment() {
// tag::layout[]
- TextArea textArea1 = new TextArea("Text area 1");
HorizontalLayout layout = new HorizontalLayout();
layout.setPadding(true);
layout.setAlignItems(FlexComponent.Alignment.STRETCH);
- layout.add(textArea1);
- layout.setAlignSelf(FlexComponent.Alignment.START, textArea1);
- layout.add(new TextArea("Text area 2"));
- TextArea textArea3 = new TextArea("Text area 3");
- layout.add(textArea3);
- layout.setAlignSelf(FlexComponent.Alignment.END, textArea3);
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+ layout.add(item1);
+ layout.setAlignSelf(FlexComponent.Alignment.START, item1);
+
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+ layout.add(item2);
+
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+ layout.add(item3);
+ layout.setAlignSelf(FlexComponent.Alignment.END, item3);
// end::layout[]
this.setClassName("basic-layouts-example");
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutMargin.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutMargin.java
index 350b380db2..0beb406758 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutMargin.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutMargin.java
@@ -2,7 +2,6 @@
import com.vaadin.demo.DemoExporter; // hidden-source-line
import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.html.Paragraph;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.router.Route;
@@ -15,9 +14,15 @@ public BasicLayoutsHorizontalLayoutMargin() {
HorizontalLayout layoutWithoutMargin = new HorizontalLayout();
layoutWithoutMargin.setPadding(true);
layoutWithoutMargin.setWidth("auto");
- layoutWithoutMargin.add(new Button("Button 1"));
- layoutWithoutMargin.add(new Button("Button 2"));
- layoutWithoutMargin.add(new Button("Button 3"));
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+
+ layoutWithoutMargin.add(item1, item2, item3);
Div container2 = new Div();
container2.setClassName("container");
@@ -31,9 +36,15 @@ public BasicLayoutsHorizontalLayoutMargin() {
// end::snippet[]
layoutWithMargin.setPadding(true);
layoutWithMargin.setWidth("auto");
- layoutWithMargin.add(new Button("Button 1"));
- layoutWithMargin.add(new Button("Button 2"));
- layoutWithMargin.add(new Button("Button 3"));
+
+ Div marginItem1 = new Div("Item 1");
+ marginItem1.setClassName("example-item");
+ Div marginItem2 = new Div("Item 2");
+ marginItem2.setClassName("example-item");
+ Div marginItem3 = new Div("Item 3");
+ marginItem3.setClassName("example-item");
+
+ layoutWithMargin.add(marginItem1, marginItem2, marginItem3);
Div container1 = new Div();
container1.setClassName("container");
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutPadding.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutPadding.java
index d3a86db9e3..2df8873bbb 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutPadding.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutPadding.java
@@ -2,7 +2,6 @@
import com.vaadin.demo.DemoExporter; // hidden-source-line
import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.html.Paragraph;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.router.Route;
@@ -13,9 +12,15 @@ public class BasicLayoutsHorizontalLayoutPadding extends Div {
public BasicLayoutsHorizontalLayoutPadding() {
add(new Paragraph("Horizontal layout without padding:"));
HorizontalLayout layoutWithoutPadding = new HorizontalLayout();
- layoutWithoutPadding.add(new Button("Button 1"));
- layoutWithoutPadding.add(new Button("Button 2"));
- layoutWithoutPadding.add(new Button("Button 3"));
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+
+ layoutWithoutPadding.add(item1, item2, item3);
this.add(layoutWithoutPadding);
add(new Paragraph("Horizontal layout with padding:"));
@@ -23,9 +28,15 @@ public BasicLayoutsHorizontalLayoutPadding() {
HorizontalLayout layoutWithPadding = new HorizontalLayout();
layoutWithPadding.setPadding(true);
// end::snippet[]
- layoutWithPadding.add(new Button("Button 1"));
- layoutWithPadding.add(new Button("Button 2"));
- layoutWithPadding.add(new Button("Button 3"));
+
+ Div paddingItem1 = new Div("Item 1");
+ paddingItem1.setClassName("example-item");
+ Div paddingItem2 = new Div("Item 2");
+ paddingItem2.setClassName("example-item");
+ Div paddingItem3 = new Div("Item 3");
+ paddingItem3.setClassName("example-item");
+
+ layoutWithPadding.add(paddingItem1, paddingItem2, paddingItem3);
this.add(layoutWithPadding);
this.setClassName("basic-layouts-example");
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutSpacing.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutSpacing.java
index fd62df168a..5a927903b7 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutSpacing.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutSpacing.java
@@ -2,7 +2,6 @@
import com.vaadin.demo.DemoExporter; // hidden-source-line
import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.html.Paragraph;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.router.Route;
@@ -18,17 +17,29 @@ public BasicLayoutsHorizontalLayoutSpacing() {
layoutWithoutSpacing.setSpacing(false);
// end::snippet[]
layoutWithoutSpacing.setPadding(true);
- layoutWithoutSpacing.add(new Button("Button 1"));
- layoutWithoutSpacing.add(new Button("Button 2"));
- layoutWithoutSpacing.add(new Button("Button 3"));
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+
+ layoutWithoutSpacing.add(item1, item2, item3);
add(layoutWithoutSpacing);
add(new Paragraph("Horizontal layout with spacing:"));
HorizontalLayout layoutWithSpacing = new HorizontalLayout();
layoutWithSpacing.setPadding(true);
- layoutWithSpacing.add(new Button("Button 1"));
- layoutWithSpacing.add(new Button("Button 2"));
- layoutWithSpacing.add(new Button("Button 3"));
+
+ Div spacingItem1 = new Div("Item 1");
+ spacingItem1.setClassName("example-item");
+ Div spacingItem2 = new Div("Item 2");
+ spacingItem2.setClassName("example-item");
+ Div spacingItem3 = new Div("Item 3");
+ spacingItem3.setClassName("example-item");
+
+ layoutWithSpacing.add(spacingItem1, spacingItem2, spacingItem3);
add(layoutWithSpacing);
this.setClassName("basic-layouts-example");
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutVerticalAlignment.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutVerticalAlignment.java
index 9df42f682e..8356aab2e0 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutVerticalAlignment.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutVerticalAlignment.java
@@ -4,7 +4,6 @@
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
-import com.vaadin.flow.component.textfield.TextArea;
import com.vaadin.flow.router.Route;
@Route("basic-layouts/horizontal-layout-vertical-alignment")
@@ -15,9 +14,17 @@ public BasicLayoutsHorizontalLayoutVerticalAlignment() {
HorizontalLayout layout = new HorizontalLayout();
layout.setPadding(true);
layout.setAlignItems(FlexComponent.Alignment.CENTER);
- layout.add(new TextArea("Text area 1"));
- layout.add(new TextArea("Text area 2"));
- layout.add(new TextArea("Text area 3"));
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+
+ layout.add(item1, item2, item3);
// end::layout[]
this.setClassName("basic-layouts-example");
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutWrapping.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutWrapping.java
index 8080c28c27..4de56b809e 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutWrapping.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsHorizontalLayoutWrapping.java
@@ -3,7 +3,6 @@
import com.vaadin.demo.DemoExporter; // hidden-source-line
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Paragraph;
-import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.router.Route;
@@ -17,11 +16,19 @@ public BasicLayoutsHorizontalLayoutWrapping() {
layoutWithoutWrap.setSpacing(true);
layoutWithoutWrap.setMargin(true);
layoutWithoutWrap.setWidth("350px");
- layoutWithoutWrap.add(new Button("Button 1"));
- layoutWithoutWrap.add(new Button("Button 2"));
- layoutWithoutWrap.add(new Button("Button 3"));
- layoutWithoutWrap.add(new Button("Button 4"));
- layoutWithoutWrap.add(new Button("Button 5"));
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+ Div item4 = new Div("Item 4");
+ item4.setClassName("example-item");
+ Div item5 = new Div("Item 5");
+ item5.setClassName("example-item");
+
+ layoutWithoutWrap.add(item1, item2, item3, item4, item5);
this.add(layoutWithoutWrap);
add(new Paragraph("Horizontal layout with wrapping:"));
@@ -33,11 +40,19 @@ public BasicLayoutsHorizontalLayoutWrapping() {
layoutWithWrap.setPadding(true);
layoutWithWrap.setSpacing(true);
layoutWithWrap.setWidth("350px");
- layoutWithWrap.add(new Button("Button 1"));
- layoutWithWrap.add(new Button("Button 2"));
- layoutWithWrap.add(new Button("Button 3"));
- layoutWithWrap.add(new Button("Button 4"));
- layoutWithWrap.add(new Button("Button 5"));
+
+ Div wrapItem1 = new Div("Item 1");
+ wrapItem1.setClassName("example-item");
+ Div wrapItem2 = new Div("Item 2");
+ wrapItem2.setClassName("example-item");
+ Div wrapItem3 = new Div("Item 3");
+ wrapItem3.setClassName("example-item");
+ Div wrapItem4 = new Div("Item 4");
+ wrapItem4.setClassName("example-item");
+ Div wrapItem5 = new Div("Item 5");
+ wrapItem5.setClassName("example-item");
+
+ layoutWithWrap.add(wrapItem1, wrapItem2, wrapItem3, wrapItem4, wrapItem5);
this.setClassName("basic-layouts-example");
this.add(layoutWithWrap);
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsMargin.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsMargin.java
index ca6e35e4f2..086113f22a 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsMargin.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsMargin.java
@@ -2,7 +2,6 @@
import com.vaadin.demo.DemoExporter; // hidden-source-line
import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.html.Paragraph;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
@@ -29,9 +28,16 @@ public BasicLayoutsMargin() {
VerticalLayout layoutWithoutMargin = new VerticalLayout();
layoutWithoutMargin.setWidth("auto");
layoutWithoutMargin.setAlignItems(FlexComponent.Alignment.STRETCH);
- layoutWithoutMargin.add(new Button("Button 1"));
- layoutWithoutMargin.add(new Button("Button 2"));
- layoutWithoutMargin.add(new Button("Button 3"));
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+
+ layoutWithoutMargin.add(item1, item2, item3);
+
container.add(layoutWithoutMargin);
wrapper = new Div();
@@ -49,9 +55,16 @@ public BasicLayoutsMargin() {
// end::snippet[]
layoutWithMargin.setWidth("auto");
layoutWithMargin.setAlignItems(FlexComponent.Alignment.STRETCH);
- layoutWithMargin.add(new Button("Button 1"));
- layoutWithMargin.add(new Button("Button 2"));
- layoutWithMargin.add(new Button("Button 3"));
+
+ Div marginItem1 = new Div("Item 1");
+ marginItem1.setClassName("example-item");
+ Div marginItem2 = new Div("Item 2");
+ marginItem2.setClassName("example-item");
+ Div marginItem3 = new Div("Item 3");
+ marginItem3.setClassName("example-item");
+
+ layoutWithMargin.add(marginItem1, marginItem2, marginItem3);
+
container.add(layoutWithMargin);
setClassName("basic-layouts-example");
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsPadding.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsPadding.java
index f1a415cb80..b00ce97924 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsPadding.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsPadding.java
@@ -2,7 +2,6 @@
import com.vaadin.demo.DemoExporter; // hidden-source-line
import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.html.Paragraph;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
@@ -28,9 +27,15 @@ public BasicLayoutsPadding() {
layoutWithoutPadding.setPadding(false);
// end::snippet[]
layoutWithoutPadding.setAlignItems(FlexComponent.Alignment.STRETCH);
- layoutWithoutPadding.add(new Button("Button 1"));
- layoutWithoutPadding.add(new Button("Button 2"));
- layoutWithoutPadding.add(new Button("Button 3"));
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+
+ layoutWithoutPadding.add(item1, item2, item3);
wrapper.add(layoutWithoutPadding);
wrapper = new Div();
@@ -40,9 +45,15 @@ public BasicLayoutsPadding() {
VerticalLayout layoutWithPadding = new VerticalLayout();
layoutWithPadding.setAlignItems(FlexComponent.Alignment.STRETCH);
- layoutWithPadding.add(new Button("Button 1"));
- layoutWithPadding.add(new Button("Button 2"));
- layoutWithPadding.add(new Button("Button 3"));
+
+ Div paddingItem1 = new Div("Item 1");
+ paddingItem1.setClassName("example-item");
+ Div paddingItem2 = new Div("Item 2");
+ paddingItem2.setClassName("example-item");
+ Div paddingItem3 = new Div("Item 3");
+ paddingItem3.setClassName("example-item");
+
+ layoutWithPadding.add(paddingItem1, paddingItem2, paddingItem3);
wrapper.add(layoutWithPadding);
setClassName("basic-layouts-example");
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsSpacing.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsSpacing.java
index 5368488a2b..9cc91ba6ce 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsSpacing.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsSpacing.java
@@ -2,7 +2,6 @@
import com.vaadin.demo.DemoExporter; // hidden-source-line
import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.html.Paragraph;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
@@ -28,9 +27,15 @@ public BasicLayoutsSpacing() {
layoutWithoutSpacing.setSpacing(false);
// end::snippet[]
layoutWithoutSpacing.setAlignItems(FlexComponent.Alignment.STRETCH);
- layoutWithoutSpacing.add(new Button("Button 1"));
- layoutWithoutSpacing.add(new Button("Button 2"));
- layoutWithoutSpacing.add(new Button("Button 3"));
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+
+ layoutWithoutSpacing.add(item1, item2, item3);
wrapper.add(layoutWithoutSpacing);
wrapper = new Div();
@@ -40,9 +45,15 @@ public BasicLayoutsSpacing() {
VerticalLayout layoutWithSpacing = new VerticalLayout();
layoutWithSpacing.setAlignItems(FlexComponent.Alignment.STRETCH);
- layoutWithSpacing.add(new Button("Button 1"));
- layoutWithSpacing.add(new Button("Button 2"));
- layoutWithSpacing.add(new Button("Button 3"));
+
+ Div spacingItem1 = new Div("Item 1");
+ spacingItem1.setClassName("example-item");
+ Div spacingItem2 = new Div("Item 2");
+ spacingItem2.setClassName("example-item");
+ Div spacingItem3 = new Div("Item 3");
+ spacingItem3.setClassName("example-item");
+
+ layoutWithSpacing.add(spacingItem1, spacingItem2, spacingItem3);
wrapper.add(layoutWithSpacing);
setClassName("basic-layouts-example");
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayout.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayout.java
index 7d44bd9c55..b555d44b30 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayout.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayout.java
@@ -2,7 +2,6 @@
import com.vaadin.demo.DemoExporter; // hidden-source-line
import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;
@@ -11,9 +10,17 @@ public class BasicLayoutsVerticalLayout extends Div {
public BasicLayoutsVerticalLayout() {
// tag::snippet[]
VerticalLayout layout = new VerticalLayout();
- layout.add(new Button("Button 1"));
- layout.add(new Button("Button 2"));
- layout.add(new Button("Button 3"));
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+
+ layout.add(item1, item2, item3);
// end::snippet[]
this.setClassName("basic-layouts-example");
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutHorizontalAlignment.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutHorizontalAlignment.java
index 791f5263b6..fe844c0529 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutHorizontalAlignment.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutHorizontalAlignment.java
@@ -2,7 +2,6 @@
import com.vaadin.demo.DemoExporter; // hidden-source-line
import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;
@@ -14,9 +13,17 @@ public BasicLayoutsVerticalLayoutHorizontalAlignment() {
// tag::layout[]
VerticalLayout layout = new VerticalLayout();
layout.setAlignItems(FlexComponent.Alignment.CENTER);
- layout.add(new Button("Button 1"));
- layout.add(new Button("Button 2"));
- layout.add(new Button("Button 3"));
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+
+ layout.add(item1, item2, item3);
// end::layout[]
this.setClassName("basic-layouts-example");
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutIndividualAlignment.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutIndividualAlignment.java
index 3402d4f5d7..bf4a795776 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutIndividualAlignment.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutIndividualAlignment.java
@@ -2,8 +2,6 @@
import com.vaadin.demo.DemoExporter; // hidden-source-line
import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.component.button.Button;
-import com.vaadin.flow.component.button.ButtonVariant;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.component.orderedlayout.FlexComponent.Alignment;
@@ -14,16 +12,22 @@ public class BasicLayoutsVerticalLayoutIndividualAlignment extends Div {
public BasicLayoutsVerticalLayoutIndividualAlignment() {
// tag::layout[]
- Button button1 = new Button("Button 1");
- Button button2 = new Button("Button 2");
- button1.addThemeVariants(ButtonVariant.LUMO_PRIMARY);
VerticalLayout layout = new VerticalLayout();
- layout.add(button1);
- layout.setAlignSelf(Alignment.END, button1);
- layout.add(button2);
- layout.setAlignSelf(Alignment.CENTER, button2);
layout.setAlignItems(FlexComponent.Alignment.START);
- layout.add(new Button("Button 3"));
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+ layout.add(item1);
+ layout.setAlignSelf(Alignment.END, item1);
+
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+ layout.add(item2);
+ layout.setAlignSelf(Alignment.CENTER, item2);
+
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+ layout.add(item3);
// end::layout[]
this.setClassName("basic-layouts-example");
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutVerticalAlignment.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutVerticalAlignment.java
index f6d683b28c..e18540637e 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutVerticalAlignment.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutVerticalAlignment.java
@@ -2,7 +2,6 @@
import com.vaadin.demo.DemoExporter; // hidden-source-line
import com.vaadin.flow.component.html.Div;
-import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
import com.vaadin.flow.router.Route;
@@ -14,9 +13,17 @@ public BasicLayoutsVerticalLayoutVerticalAlignment() {
// tag::layout[]
VerticalLayout layout = new VerticalLayout();
layout.setJustifyContentMode(FlexComponent.JustifyContentMode.CENTER);
- layout.add(new Button("Button 1"));
- layout.add(new Button("Button 2"));
- layout.add(new Button("Button 3"));
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+
+ layout.add(item1, item2, item3);
// end::layout[]
this.setClassName("basic-layouts-example");
diff --git a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutWrapping.java b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutWrapping.java
index 6776db7d5d..aa17ae5cbd 100644
--- a/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutWrapping.java
+++ b/src/main/java/com/vaadin/demo/component/basiclayouts/BasicLayoutsVerticalLayoutWrapping.java
@@ -3,7 +3,6 @@
import com.vaadin.demo.DemoExporter; // hidden-source-line
import com.vaadin.flow.component.html.Div;
import com.vaadin.flow.component.html.Paragraph;
-import com.vaadin.flow.component.button.Button;
import com.vaadin.flow.component.orderedlayout.FlexComponent;
import com.vaadin.flow.component.orderedlayout.HorizontalLayout;
import com.vaadin.flow.component.orderedlayout.VerticalLayout;
@@ -27,10 +26,17 @@ public BasicLayoutsVerticalLayoutWrapping() {
layoutWithoutWrap.setSpacing(true);
layoutWithoutWrap.setAlignItems(FlexComponent.Alignment.STRETCH);
layoutWithoutWrap.setHeight("200px");
- layoutWithoutWrap.add(new Button("Button 1"));
- layoutWithoutWrap.add(new Button("Button 2"));
- layoutWithoutWrap.add(new Button("Button 3"));
- layoutWithoutWrap.add(new Button("Button 4"));
+
+ Div item1 = new Div("Item 1");
+ item1.setClassName("example-item");
+ Div item2 = new Div("Item 2");
+ item2.setClassName("example-item");
+ Div item3 = new Div("Item 3");
+ item3.setClassName("example-item");
+ Div item4 = new Div("Item 4");
+ item4.setClassName("example-item");
+
+ layoutWithoutWrap.add(item1, item2, item3, item4);
wrapper.add(layoutWithoutWrap);
parent.add(wrapper);
@@ -46,11 +52,17 @@ public BasicLayoutsVerticalLayoutWrapping() {
layoutWithWrap.setSpacing(true);
layoutWithWrap.setAlignItems(FlexComponent.Alignment.STRETCH);
layoutWithWrap.setHeight("200px");
- layoutWithWrap.add(new Button("Button 1"));
- layoutWithWrap.add(new Button("Button 2"));
- layoutWithWrap.add(new Button("Button 3"));
- layoutWithWrap.add(new Button("Button 4"));
-
+
+ Div wrapItem1 = new Div("Item 1");
+ wrapItem1.setClassName("example-item");
+ Div wrapItem2 = new Div("Item 2");
+ wrapItem2.setClassName("example-item");
+ Div wrapItem3 = new Div("Item 3");
+ wrapItem3.setClassName("example-item");
+ Div wrapItem4 = new Div("Item 4");
+ wrapItem4.setClassName("example-item");
+
+ layoutWithWrap.add(wrapItem1, wrapItem2, wrapItem3, wrapItem4);
wrapper.add(layoutWithWrap);
parent.add(wrapper);
this.setClassName("basic-layouts-example");