It includes all kinds of input items, such as `input`, `select`, `radio` and `checkbox`.
:::demo In each `form` component, you need a `form-item` field to be the container of your input item.
form/basic-form
:::
:::tip
[W3C](https://www.w3.org/MarkUp/html-spec/html-spec_8.html#SEC8.2) regulates that
> <i>When there is only one single-line text input field in a form, the user agent should accept Enter in that field as a request to submit the form.</i>
To prevent this behavior, you can add `@submit.prevent` on `<el-form>`.
When the vertical space is limited and the form is relatively simple, you can put it in one line.
:::demo Set the `inline` attribute to `true` and the form will be inline.
form/inline-form
:::
## Alignment
Depending on your design, there are several different ways to align your label element.
:::demo The `label-position` attribute decides how labels align, it can be `top` or `left`. When set to `top`, labels will be placed at the top of the form field.
form/alignment
:::
## Validation
Form component allows you to verify your data, helping you find and correct errors.
:::demo Just add the `rules` attribute for `Form` component, pass validation rules, and set `prop` attribute for `FormItem` as a specific key that needs to be validated. See more information at [async-validator](https://github.com/yiminghe/async-validator).
:::demo In addition to passing all validation rules at once on the form component, you can also pass the validation rules or delete rules on a single form field dynamically.
:::demo Number Validate need a `.number` modifier added on the input `v-model` binding,it's used to transform the string value to the number which is provided by Vue.
When only a single input (or related control such as select or checkbox) is inside of a `el-form-item`, the form item's label will automatically be attached to that input. However, if multiple inputs are inside of the `el-form-item`, the form item will be assigned the [WAI-ARIA](https://www.w3.org/WAI/standards-guidelines/aria/) role of [group](https://www.w3.org/TR/wai-aria/#group) instead. In this case, it is your responsibility to assign assistive labels to the individual inputs.
| `inline` | Whether the form is inline. | `boolean` | `false` |
| `label-position` | Position of label. If set to `'left'` or `'right'`, `label-width` prop is also required. | `'left' \| 'right' \| 'top'` | `'right'` |
| `label-width` | Width of label, e.g. `'50px'`. All its direct child form items will inherit this value. `auto` is supported. | `string \| number` | — |
| `label-suffix` | Suffix of the label. | `string` | — |
| `hide-required-asterisk` | Whether required fields should have a red asterisk (star) beside their labels. | `boolean` | `false` |
| `show-message` | Whether to show the error message. | `boolean` | `true` |
| `inline-message` | Whether to display the error message inline with the form item. | `boolean` | `false` |
| `status-icon` | Whether to display an icon indicating the validation result. | `boolean` | `false` |
| `validate-on-rule-change` | Whether to trigger validation when the `rules` prop is changed. | `boolean` | `true` |
| `size` | Control the size of components in this form. | `'large' \| 'default' \| 'small'` | — |
| `disabled` | Whether to disable all components in this form. If set to `true`, it will override the `disabled` prop of the inner component. | `boolean` | `false` |
| `prop` | A key of `model`. It could be an array of property paths (e.g `['a', 'b', 0]`). In the use of `validate` and `resetFields` method, the attribute is required. | `string \| string[]` | — |
| `label` | Label text. | `string` | — |
| `label-width` | Width of label, e.g. `'50px'`. `'auto'` is supported. | `string \| number` | — |
| `required` | Whether the field is required or not, will be determined by validation rules if omitted. | `boolean` | `false` |
| `rules` | Validation rules of form, see the [following table](#formitemrule), more advanced usage at [async-validator](https://github.com/yiminghe/async-validator). | `FormItemRule \| FormItemRule[]` | — |
| `error` | Field error message, set its value and the field will validate error and show this message immediately. | `string` | — |
| `show-message` | Whether to show the error message. | `boolean` | `true` |