2020-01-03 13:38:16 +08:00
|
|
|
---
|
|
|
|
order: 2
|
|
|
|
title:
|
|
|
|
zh-CN: 组件尺寸
|
|
|
|
en-US: Component size
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
修改默认组件尺寸。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Config component default size.
|
|
|
|
|
|
|
|
```jsx
|
2020-01-22 12:11:49 +08:00
|
|
|
import React, { useState } from 'react';
|
2020-01-03 13:38:16 +08:00
|
|
|
import {
|
|
|
|
ConfigProvider,
|
|
|
|
Radio,
|
|
|
|
Input,
|
|
|
|
Button,
|
|
|
|
Select,
|
|
|
|
DatePicker,
|
|
|
|
Divider,
|
|
|
|
Table,
|
|
|
|
Card,
|
2021-03-24 12:23:24 +08:00
|
|
|
Tabs,
|
2020-01-03 13:38:16 +08:00
|
|
|
} from 'antd';
|
|
|
|
|
2021-03-24 12:23:24 +08:00
|
|
|
const { TabPane } = Tabs;
|
|
|
|
|
2020-01-03 13:38:16 +08:00
|
|
|
const FormSizeDemo = () => {
|
2020-01-22 12:11:49 +08:00
|
|
|
const [componentSize, setComponentSize] = useState('small');
|
2020-01-03 13:38:16 +08:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Radio.Group
|
|
|
|
value={componentSize}
|
|
|
|
onChange={e => {
|
|
|
|
setComponentSize(e.target.value);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Radio.Button value="small">Small</Radio.Button>
|
|
|
|
<Radio.Button value="middle">Middle</Radio.Button>
|
|
|
|
<Radio.Button value="large">Large</Radio.Button>
|
|
|
|
</Radio.Group>
|
|
|
|
<Divider />
|
|
|
|
<ConfigProvider componentSize={componentSize}>
|
|
|
|
<div className="example">
|
|
|
|
<Input />
|
|
|
|
</div>
|
2021-03-24 12:23:24 +08:00
|
|
|
<div className="example">
|
|
|
|
<Tabs defaultActiveKey="1">
|
|
|
|
<TabPane tab="Tab 1" key="1">
|
|
|
|
Content of Tab Pane 1
|
|
|
|
</TabPane>
|
|
|
|
<TabPane tab="Tab 2" key="2">
|
|
|
|
Content of Tab Pane 2
|
|
|
|
</TabPane>
|
|
|
|
<TabPane tab="Tab 3" key="3">
|
|
|
|
Content of Tab Pane 3
|
|
|
|
</TabPane>
|
|
|
|
</Tabs>
|
|
|
|
</div>
|
2020-04-18 18:31:03 +08:00
|
|
|
<div className="example">
|
2020-04-21 09:41:09 +08:00
|
|
|
<Input.Search allowClear />
|
2020-04-18 18:31:03 +08:00
|
|
|
</div>
|
2020-10-12 20:39:51 +08:00
|
|
|
<div className="example">
|
|
|
|
<Input.TextArea allowClear />
|
|
|
|
</div>
|
2020-01-03 13:38:16 +08:00
|
|
|
<div className="example">
|
|
|
|
<Select defaultValue="demo" options={[{ value: 'demo' }]} />
|
|
|
|
</div>
|
|
|
|
<div className="example">
|
|
|
|
<DatePicker />
|
|
|
|
</div>
|
2020-03-22 15:52:02 +08:00
|
|
|
<div className="example">
|
|
|
|
<DatePicker.RangePicker />
|
|
|
|
</div>
|
2020-01-03 13:38:16 +08:00
|
|
|
<div className="example">
|
|
|
|
<Button>Button</Button>
|
|
|
|
</div>
|
|
|
|
<div className="example">
|
|
|
|
<Card title="Card">
|
|
|
|
<Table
|
|
|
|
columns={[
|
|
|
|
{ title: 'Name', dataIndex: 'name' },
|
|
|
|
{ title: 'Age', dataIndex: 'age' },
|
|
|
|
]}
|
|
|
|
dataSource={[
|
|
|
|
{
|
|
|
|
key: '1',
|
|
|
|
name: 'John Brown',
|
|
|
|
age: 32,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '2',
|
|
|
|
name: 'Jim Green',
|
|
|
|
age: 42,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: '3',
|
|
|
|
name: 'Joe Black',
|
|
|
|
age: 32,
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
|
|
|
</Card>
|
|
|
|
</div>
|
|
|
|
</ConfigProvider>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
ReactDOM.render(<FormSizeDemo />, mountNode);
|
|
|
|
```
|