diff --git a/components/form/demo/layout.md b/components/form/demo/layout.md new file mode 100644 index 0000000000..6c93b863a7 --- /dev/null +++ b/components/form/demo/layout.md @@ -0,0 +1,75 @@ +--- +order: 13 +title: + zh-CN: 表单布局 + en-US: Form Layout +--- + +## zh-CN + +表单有三种布局。 + +## en-US + +There are three layout for form: `horizontal`, `vertical`, `inline`. + +````jsx +import { Form, Input, Button, Radio } from 'antd'; +const FormItem = Form.Item; + +class FormLayoutDemo extends React.Component { + constructor() { + super(); + this.state = { + formLayout: 'horizontal', + }; + } + handleFormLayoutChange = (e) => { + this.setState({ formLayout: e.target.value }); + } + render() { + const { formLayout } = this.state; + const formItemLayout = formLayout === 'horizontal' ? { + labelCol: { span: 4 }, + wrapperCol: { span: 14 }, + } : null; + const buttonItemLayout = formLayout === 'horizontal' ? { + wrapperCol: { span: 14, offset: 4 }, + } : null; + const layoutProps = { [formLayout]: true }; + return ( +
+
+ + + Horizontal + Vertical + Inline + + + + + + + + + + + +
+
+ ); + } +} + +ReactDOM.render(, mountNode); +```` diff --git a/components/form/index.en-US.md b/components/form/index.en-US.md index 6dbb3bf831..e34c576507 100644 --- a/components/form/index.en-US.md +++ b/components/form/index.en-US.md @@ -12,7 +12,8 @@ Form is used to collect, validate, and submit the user input, usually contains v You can align the controls of a `form` using one of the following attributes: - `horizontal`:to horizontally align the `label`s and controls of the fields. -- `inline`:to render the labels and controls of the fields in one line (by setting the display property of form controls to `inline-block`). +- `vertical`:to vertically align the `label`s and controls of the fields. +- `inline`:to render form fields in one line. ## Form fields diff --git a/components/form/index.zh-CN.md b/components/form/index.zh-CN.md index 3f9782e3c0..81ec3116ad 100644 --- a/components/form/index.zh-CN.md +++ b/components/form/index.zh-CN.md @@ -12,8 +12,9 @@ title: Form 我们为 `form` 提供了以下两种排列方式: -- 水平排列:可以实现 `label` 标签和表单控件的水平排列; -- 行内排列:使其表现为 `inline-block` 级别的控件。 +- 水平排列:标签和表单控件水平排列; +- 水质排列:标签和表单控件上下垂直排列; +- 行内排列:表单项水平行内排列。 ## 表单域 diff --git a/components/form/style/index.less b/components/form/style/index.less index fb587dfedf..3c625a0198 100644 --- a/components/form/style/index.less +++ b/components/form/style/index.less @@ -253,6 +253,8 @@ form { .@{form-prefix-cls}-vertical { .@{form-prefix-cls}-item-label { padding: 0 0 8px; + display: block; + text-align: left; label:after { content: '';