mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 17:31:25 +08:00
20d5502193
* chore(deps-dev): bump eslint-config-airbnb from 18.2.1 to 19.0.0 Bumps [eslint-config-airbnb](https://github.com/airbnb/javascript) from 18.2.1 to 19.0.0. - [Release notes](https://github.com/airbnb/javascript/releases) - [Commits](https://github.com/airbnb/javascript/compare/eslint-config-airbnb-v18.2.1...eslint-config-airbnb-v19.0.0) --- updated-dependencies: - dependency-name: eslint-config-airbnb dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * chore: code style * memoize-one * add comment * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * fix lint * improve useMemo deps Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: afc163 <afc163@gmail.com>
103 lines
2.3 KiB
Markdown
103 lines
2.3 KiB
Markdown
---
|
|
order: 3.1
|
|
title:
|
|
zh-CN: 表单尺寸
|
|
en-US: Form size
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
设置表单组件尺寸,仅对 antd 组件有效。
|
|
|
|
## en-US
|
|
|
|
Set component size, only works for antd components.
|
|
|
|
```tsx
|
|
import React, { useState } from 'react';
|
|
import {
|
|
Form,
|
|
Input,
|
|
Button,
|
|
Radio,
|
|
Select,
|
|
Cascader,
|
|
DatePicker,
|
|
InputNumber,
|
|
TreeSelect,
|
|
Switch,
|
|
} from 'antd';
|
|
|
|
type SizeType = Parameters<typeof Form>[0]['size'];
|
|
|
|
const FormSizeDemo = () => {
|
|
const [componentSize, setComponentSize] = useState<SizeType | 'default'>('default');
|
|
const onFormLayoutChange = ({ size }: { size: SizeType }) => {
|
|
setComponentSize(size);
|
|
};
|
|
return (
|
|
<Form
|
|
labelCol={{ span: 4 }}
|
|
wrapperCol={{ span: 14 }}
|
|
layout="horizontal"
|
|
initialValues={{ size: componentSize }}
|
|
onValuesChange={onFormLayoutChange}
|
|
size={componentSize as SizeType}
|
|
>
|
|
<Form.Item label="Form Size" name="size">
|
|
<Radio.Group>
|
|
<Radio.Button value="small">Small</Radio.Button>
|
|
<Radio.Button value="default">Default</Radio.Button>
|
|
<Radio.Button value="large">Large</Radio.Button>
|
|
</Radio.Group>
|
|
</Form.Item>
|
|
<Form.Item label="Input">
|
|
<Input />
|
|
</Form.Item>
|
|
<Form.Item label="Select">
|
|
<Select>
|
|
<Select.Option value="demo">Demo</Select.Option>
|
|
</Select>
|
|
</Form.Item>
|
|
<Form.Item label="TreeSelect">
|
|
<TreeSelect
|
|
treeData={[
|
|
{ title: 'Light', value: 'light', children: [{ title: 'Bamboo', value: 'bamboo' }] },
|
|
]}
|
|
/>
|
|
</Form.Item>
|
|
<Form.Item label="Cascader">
|
|
<Cascader
|
|
options={[
|
|
{
|
|
value: 'zhejiang',
|
|
label: 'Zhejiang',
|
|
children: [
|
|
{
|
|
value: 'hangzhou',
|
|
label: 'Hangzhou',
|
|
},
|
|
],
|
|
},
|
|
]}
|
|
/>
|
|
</Form.Item>
|
|
<Form.Item label="DatePicker">
|
|
<DatePicker />
|
|
</Form.Item>
|
|
<Form.Item label="InputNumber">
|
|
<InputNumber />
|
|
</Form.Item>
|
|
<Form.Item label="Switch" valuePropName="checked">
|
|
<Switch />
|
|
</Form.Item>
|
|
<Form.Item label="Button">
|
|
<Button>Button</Button>
|
|
</Form.Item>
|
|
</Form>
|
|
);
|
|
};
|
|
|
|
ReactDOM.render(<FormSizeDemo />, mountNode);
|
|
```
|