You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* docs: document FormLayout style properties
* change order of table rows
* alternative wording
* Update articles/components/form-layout/index.adoc
* simplify wording
* limit since to only Flow
* Update articles/components/form-layout/index.adoc
Co-authored-by: Jouni Koivuviita <[email protected]>
* Editing changed text and some minor items.
* Full editing of document touched.
* Second pass at full editing of document touched.
---------
Co-authored-by: Jouni Koivuviita <[email protected]>
Co-authored-by: russelljtdyer <[email protected]>
By default, Form Layout has two columns, meaning it displays two input fields per line. When the layout width is smaller, it adjusts to a single-column.
45
+
By default, Form Layout has two columns: it displays two input fields per line. When the layout width is smaller, it adjusts to a single-column.
45
46
46
-
=== Custom Layout
47
47
48
-
You can define how many columns Form Layout should use based on the screen width.
48
+
=== Custom Layout
49
49
50
-
[IMPORTANT]
51
-
Use the draggable split handle to resize Form Layout's available space and to test its responsiveness.
50
+
You can define how many columns that Form Layout should use based on the screen width. Use the draggable split handle to resize Form Layout's available space and to test its responsiveness.
A single-column layout is preferable to a multi-column one. A multi-column layout can be prone to confusion and misinterpretation by the user.
79
-
80
-
However, related fields can be placed in a line without confusion, typically. Examples of this would be first and last name, address fields such as postal code and city, and ranged input for dates, time, and currency.
77
+
A single-column layout is preferable to a multi-column layout. A multi-column layout can be prone to confusion and misinterpretation by the user. However, related fields placed in a line are typically understandable. Examples of this would be first and last name, address fields such as city and postal code, and ranged input for dates, time, and price or cost.
81
78
82
79
83
80
=== Column Span
84
81
85
82
When using a multi-column layout, you can define a `colspan` for each component. The `colspan` determines how many columns a component extends or stretches across.
86
83
87
-
For example, if you have a Form Layout with three columns and a component's `colspan` is set to 3, it takes up the entire width of the Form Layout.
84
+
For example, if you have a Form Layout with three columns and a component's `colspan` is set to 3, it'll therefore take the entire width of the Form Layout.
Input fields' built-in labels are positioned above the input. Form Layout supports side-positioned labels, provided they are wrapped in Form Items and the label position is set to `aside`.
114
+
The built-in labels for input fields are positioned above the input. Form Layout supports side-positioned labels, provided they're wrapped in Form Items and the label position is set to `aside`.
117
115
118
116
The only reason for wrapping labels in Form Items is to put the labels to the side of the input.
119
117
118
+
120
119
=== Top
121
120
122
-
Users complete forms that have top-positioned labels more quickly because they provide a consistent scanning pattern -- top-down, as opposed to zigzag -- while minimizing the distance between the label and input.
121
+
Users complete forms that have top-positioned labels more quickly because they provide a consistent scanning pattern -- top-down, as opposed to zigzag -- while minimizing the distance between the label and input field.
123
122
124
123
Top-positioned labels are also less prone to causing layout issues due to variable label lengths, which happens usually in multilingual applications. However, they do result in vertically longer forms. This is why <<#sectioning,sectioning>> is important.
125
124
125
+
126
126
=== Side
127
127
128
128
Side-positioned labels help reduce a form's total height. This is especially useful for longer forms and when vertical space is limited.
129
129
130
-
Labels positioned on the side are also often used when there is a need to compare numeric data.
130
+
The positioning of labels on the side is also useful when there's a need to compare numeric data.
Aim for similar-length labels to keep the distance between the labels and input fields consistent. Inconsistent spacing can slow the user in completing the form.
157
+
Aim for similar-length labels to keep the distance consistent between the labels and the input fields. Inconsistent spacing can slow the user in completing a form.
158
+
159
+
Forms that use this position require more horizontal space, which isn't always ideal in narrow forms. Instead, configure Form Layout to use top-positioned labels when the form has a narrow width.
158
160
159
-
Forms that use this position require more horizontal space, which isn't always ideal in narrow forms. It's recommended to configure Form Layout to use top-positioned labels when the form has a narrow width.
161
+
The width of side-positioned labels can be adjusted using the `--vaadin-form-item-label-width` CSS property on the Form Layout element, or with the [since:com.vaadin:[email protected]]#[methodname]`setLabelWidth()` method# on the [classname]`FormLayout` instance in Flow.
160
162
161
163
162
164
=== Responsive Label Position
163
165
164
-
Similar to the number of columns, the label position is configurable based on the width of the layout. For example, you can position the labels to the side when there is ample horizontal space available, and on top for narrower screens.
166
+
Similar to the number of columns, the label position is configurable based on the width of the layout. For example, you can position the labels to the side when there's ample horizontal space available, and on top for narrower screens.
167
+
168
+
169
+
== Spacing
170
+
171
+
Form Layout allows you to configure the spacing between columns, rows, and between the label and input field when labels are positioned on the side.
172
+
173
+
To configure the spacing, use the following CSS properties on the Form Layout element:
Form Item only supports placing a single field inside. Where you need to place multiple fields, <<../custom-field#,Custom Field>> should be used as a wrapper:
Keeping fields in individual Form Items, however, is preferable. Wrapped fields can be hard to distinguish visually since they usually have no individual label except for a placeholder, which is only visible when the field has no value.
250
+
Keeping fields in individual Form Items is preferable. Wrapped fields can be hard to distinguish visually since they usually have no individual label except for a placeholder, which is only visible when the field has no value.
251
+
226
252
227
253
== Best Practices
228
254
255
+
With regards to developing with Form Layout, this section provides some suggestions for better user experiences.
256
+
257
+
229
258
=== Sectioning
230
259
231
260
Longer forms should be split into smaller, more manageable and user-friendly sections using sub-headings, <<../tabs#,Tabs>>, <<../details#,Details>> or separate views when possible. Each section should consist of related content and fields.
232
261
262
+
233
263
=== Button Placement
234
264
235
265
Use the following guidelines for Button placement in forms:
236
266
237
-
* Buttons should be placed below the form with which they are associated.
238
-
* Buttons should be aligned to the left.
239
-
* Primary action should be placed first, followed by other actions, in order of importance.
267
+
- Buttons should be placed below the form with which they're associated.
268
+
- Buttons should be aligned to the left.
269
+
- Primary action should be placed first, followed by other actions, in order of importance.
240
270
241
271
For more information, see the <<../button#,Button documentation>>.
0 commit comments