@ui5/webcomponents-react
Version:
React Wrapper for UI5 Web Components and additional components
85 lines (84 loc) • 4.18 kB
JavaScript
'use client';
import '@ui5/webcomponents/dist/Form.js';
import { withWebComponent } from '../../internal/withWebComponent.js';
/**
* The Form is a layout component that arranges labels and form fields (like input fields) pairs
* into a specific number of columns.
*
* ### Structure
*
* - **Form** (`Form`) is the top-level container component, responsible for the content layout and responsiveness.
* - **FormGroup** (`FormGroup`) enables the grouping of the Form content.
* - **FormItem** (`FormItem`) is a pair of label and form fields and can be used directly in a Form, or as part of a FormGroup.
*
* The simplest Form (`Form`) consists of a header area on top,
* displaying a header text (see the `headingText` property) and content below - an arbitrary number of FormItems (ui5-form-item),
* representing the pairs of label and form fields.
*
* And, there is also "grouping" available to assist the implementation of richer UIs.
* This is enabled by the FormGroup (`FormGroup`) component.
* In this case, the Form is structured into FormGroups and each FormGroup consists of FormItems.
*
* ### Responsiveness
*
* The Form component reacts and changes its layout on predefined breakpoints.
* Depending on its size, the Form content (FormGroups and FormItems) gets divided into one or more columns as follows:
* - **S** (< 600px) – 1 column is recommended (default: 1)
* - **M** (600px - 1022px) – up to 2 columns are recommended (default: 1)
* - **L** (1023px - 1439px) - up to 3 columns are recommended (default: 2)
* - **XL** (> 1439px) – up to 6 columns are recommended (default: 2)
*
* To change the layout, use the `layout` property - f.e. layout="S1 M2 L3 XL6".
*
* ### Groups
*
* To make better use of screen space, there is built-in logic to determine how many columns should a FormGroup occupy.
*
* - **Example #1** (perfect match):
* 4 columns and 4 groups: each group will use 1 column.
*
* - **Example #2** (balanced distribution):
* 4 columns and 2 groups: each group will use 2 columns.
* 6 columns and 2 groups: each group will use 3 columns.
*
* - **Example #3** (unbalanced distribution):
* 3 columns and 2 groups: the larger one will use 2 columns, the smaller 1 column.
* 5 columns and 3 groups: two of the groups will use 2 columns each, the smallest 1 column.
*
* **Note:** The size of a group element is determined by the number of FormItems assigned to it.
* In the case of equality, the first in the DOM will use more columns, and the last - fewer columns.
*
* - **Example #4** (more groups than columns):
* 3 columns and 4 groups: each FormGroup uses only 1 column, the last FormGroup will wrap on the second row.
*
* ### Groups Column Span
*
* To influence the built-in group distribution, described in the previous section,
* you can use the FormGroup's `columnSpan` property, that defines how many columns the group should expand to.
*
* ### Items Column Span
*
* FormItem's columnSpan property defines how many columns the form item should expand to inside a form group or the form.
*
* ### Items Label Span
*
* The placement of the labels depends on the size of the used column.
* If there is enough space, the labels are next to their associated fields, otherwise - above the fields.
* By default, the labels take 4/12 of the FormItem, leaving 8/12 parts to associated fields.
* You can control what space the labels should take via the `labelSpan` property.
*
* **For example:** To always place the labels on top set: `labelSpan="S12 M12 L12 XL12"` property.
*
* ### ES6 Module Import
*
* - import @ui5/webcomponents/dist/Form.js";
* - import @ui5/webcomponents/dist/FormGroup.js";
* - import @ui5/webcomponents/dist/FormItem.js";
*
* __Note__: This is a UI5 Web Component! [Repository](https://github.com/SAP/ui5-webcomponents) | [Documentation](https://sap.github.io/ui5-webcomponents/)
*
* @since [2.0.0](https://github.com/SAP/ui5-webcomponents/releases/tag/v2.0.0) of __@ui5/webcomponents__.
*/
const Form = withWebComponent('ui5-form', ['headerText', 'itemSpacing', 'labelSpan', 'layout'], [], ['header'], []);
Form.displayName = 'Form';
export { Form };