2016-05-25 18:21:27 +08:00
|
|
|
---
|
|
|
|
order: 3
|
2017-04-19 11:22:17 +08:00
|
|
|
title:
|
2019-05-07 14:57:32 +08:00
|
|
|
zh-CN: 输入框组合
|
|
|
|
en-US: Input Group
|
2016-05-25 18:21:27 +08:00
|
|
|
---
|
|
|
|
|
2016-08-22 09:53:39 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2016-06-16 21:15:59 +08:00
|
|
|
输入框的组合展现。
|
2016-05-25 18:21:27 +08:00
|
|
|
|
2017-01-02 00:12:41 +08:00
|
|
|
注意:使用 `compact` 模式时,不需要通过 `Col` 来控制宽度。
|
|
|
|
|
2016-08-22 09:53:39 +08:00
|
|
|
## en-US
|
|
|
|
|
2020-06-17 10:58:24 +08:00
|
|
|
Input.Group example.
|
2016-08-22 09:53:39 +08:00
|
|
|
|
2017-01-02 00:12:41 +08:00
|
|
|
Note: You don't need `Col` to control the width in the `compact` mode.
|
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
```jsx
|
2021-11-12 14:47:53 +08:00
|
|
|
import {
|
|
|
|
Input,
|
|
|
|
Button,
|
|
|
|
Col,
|
|
|
|
Row,
|
|
|
|
Select,
|
|
|
|
InputNumber,
|
|
|
|
DatePicker,
|
|
|
|
AutoComplete,
|
|
|
|
Cascader,
|
|
|
|
Tooltip,
|
|
|
|
} from 'antd';
|
|
|
|
import { CopyOutlined } from '@ant-design/icons';
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2019-05-27 21:32:45 +08:00
|
|
|
const { Option } = Select;
|
2016-05-25 18:21:27 +08:00
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
const options = [
|
|
|
|
{
|
|
|
|
value: 'zhejiang',
|
|
|
|
label: 'Zhejiang',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
value: 'hangzhou',
|
|
|
|
label: 'Hangzhou',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
value: 'xihu',
|
|
|
|
label: 'West Lake',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
value: 'jiangsu',
|
|
|
|
label: 'Jiangsu',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
value: 'nanjing',
|
|
|
|
label: 'Nanjing',
|
|
|
|
children: [
|
|
|
|
{
|
|
|
|
value: 'zhonghuamen',
|
|
|
|
label: 'Zhong Hua Men',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
2017-04-22 09:28:44 +08:00
|
|
|
|
2020-03-09 16:15:19 +08:00
|
|
|
const App = () => (
|
|
|
|
<div className="site-input-group-wrapper">
|
|
|
|
<Input.Group size="large">
|
|
|
|
<Row gutter={8}>
|
|
|
|
<Col span={5}>
|
|
|
|
<Input defaultValue="0571" />
|
|
|
|
</Col>
|
|
|
|
<Col span={8}>
|
|
|
|
<Input defaultValue="26888888" />
|
|
|
|
</Col>
|
|
|
|
</Row>
|
|
|
|
</Input.Group>
|
|
|
|
<br />
|
|
|
|
<Input.Group compact>
|
|
|
|
<Input style={{ width: '20%' }} defaultValue="0571" />
|
|
|
|
<Input style={{ width: '30%' }} defaultValue="26888888" />
|
|
|
|
</Input.Group>
|
|
|
|
<br />
|
2021-11-12 14:47:53 +08:00
|
|
|
<Input.Group compact>
|
|
|
|
<Input style={{ width: 'calc(100% - 200px)' }} defaultValue="https://ant.design" />
|
2021-11-18 14:03:26 +08:00
|
|
|
<Button type="primary">Submit</Button>
|
2021-11-12 14:47:53 +08:00
|
|
|
</Input.Group>
|
|
|
|
<br />
|
|
|
|
<Input.Group compact>
|
2021-11-18 14:03:26 +08:00
|
|
|
<Input
|
|
|
|
style={{ width: 'calc(100% - 200px)' }}
|
|
|
|
defaultValue="git@github.com:ant-design/ant-design.git"
|
|
|
|
/>
|
2021-11-12 14:47:53 +08:00
|
|
|
<Tooltip title="copy git url">
|
|
|
|
<Button icon={<CopyOutlined />} />
|
|
|
|
</Tooltip>
|
|
|
|
</Input.Group>
|
|
|
|
<br />
|
2020-03-09 16:15:19 +08:00
|
|
|
<Input.Group compact>
|
|
|
|
<Select defaultValue="Zhejiang">
|
|
|
|
<Option value="Zhejiang">Zhejiang</Option>
|
|
|
|
<Option value="Jiangsu">Jiangsu</Option>
|
|
|
|
</Select>
|
|
|
|
<Input style={{ width: '50%' }} defaultValue="Xihu District, Hangzhou" />
|
|
|
|
</Input.Group>
|
|
|
|
<br />
|
2020-10-26 10:56:09 +08:00
|
|
|
<Input.Group compact>
|
|
|
|
<Input.Search allowClear style={{ width: '40%' }} defaultValue="0571" />
|
|
|
|
<Input.Search allowClear style={{ width: '40%' }} defaultValue="26888888" />
|
2020-03-14 12:41:55 +08:00
|
|
|
</Input.Group>
|
|
|
|
<br />
|
2020-03-09 16:15:19 +08:00
|
|
|
<Input.Group compact>
|
|
|
|
<Select defaultValue="Option1">
|
|
|
|
<Option value="Option1">Option1</Option>
|
|
|
|
<Option value="Option2">Option2</Option>
|
|
|
|
</Select>
|
|
|
|
<Input style={{ width: '50%' }} defaultValue="input content" />
|
|
|
|
<InputNumber />
|
|
|
|
</Input.Group>
|
|
|
|
<br />
|
|
|
|
<Input.Group compact>
|
|
|
|
<Input style={{ width: '50%' }} defaultValue="input content" />
|
|
|
|
<DatePicker style={{ width: '50%' }} />
|
|
|
|
</Input.Group>
|
|
|
|
<br />
|
2020-04-11 20:33:08 +08:00
|
|
|
<Input.Group compact>
|
|
|
|
<Input style={{ width: '30%' }} defaultValue="input content" />
|
|
|
|
<DatePicker.RangePicker style={{ width: '70%' }} />
|
|
|
|
</Input.Group>
|
|
|
|
<br />
|
2020-03-09 16:15:19 +08:00
|
|
|
<Input.Group compact>
|
|
|
|
<Select defaultValue="Option1-1">
|
|
|
|
<Option value="Option1-1">Option1-1</Option>
|
|
|
|
<Option value="Option1-2">Option1-2</Option>
|
|
|
|
</Select>
|
|
|
|
<Select defaultValue="Option2-2">
|
|
|
|
<Option value="Option2-1">Option2-1</Option>
|
|
|
|
<Option value="Option2-2">Option2-2</Option>
|
|
|
|
</Select>
|
|
|
|
</Input.Group>
|
|
|
|
<br />
|
|
|
|
<Input.Group compact>
|
|
|
|
<Select defaultValue="1">
|
|
|
|
<Option value="1">Between</Option>
|
|
|
|
<Option value="2">Except</Option>
|
|
|
|
</Select>
|
|
|
|
<Input style={{ width: 100, textAlign: 'center' }} placeholder="Minimum" />
|
|
|
|
<Input
|
|
|
|
className="site-input-split"
|
|
|
|
style={{
|
|
|
|
width: 30,
|
|
|
|
borderLeft: 0,
|
|
|
|
borderRight: 0,
|
|
|
|
pointerEvents: 'none',
|
|
|
|
}}
|
|
|
|
placeholder="~"
|
|
|
|
disabled
|
|
|
|
/>
|
|
|
|
<Input
|
|
|
|
className="site-input-right"
|
|
|
|
style={{
|
|
|
|
width: 100,
|
|
|
|
textAlign: 'center',
|
|
|
|
}}
|
|
|
|
placeholder="Maximum"
|
|
|
|
/>
|
|
|
|
</Input.Group>
|
|
|
|
<br />
|
|
|
|
<Input.Group compact>
|
|
|
|
<Select defaultValue="Sign Up" style={{ width: '30%' }}>
|
|
|
|
<Option value="Sign Up">Sign Up</Option>
|
|
|
|
<Option value="Sign In">Sign In</Option>
|
|
|
|
</Select>
|
|
|
|
<AutoComplete
|
|
|
|
style={{ width: '70%' }}
|
|
|
|
placeholder="Email"
|
|
|
|
options={[{ value: 'text 1' }, { value: 'text 2' }]}
|
|
|
|
/>
|
|
|
|
</Input.Group>
|
|
|
|
<br />
|
|
|
|
<Input.Group compact>
|
|
|
|
<Select style={{ width: '30%' }} defaultValue="Home">
|
|
|
|
<Option value="Home">Home</Option>
|
|
|
|
<Option value="Company">Company</Option>
|
|
|
|
</Select>
|
|
|
|
<Cascader style={{ width: '70%' }} options={options} placeholder="Select Address" />
|
|
|
|
</Input.Group>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
|
|
|
ReactDOM.render(<App />, mountNode);
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|
2019-12-25 21:48:54 +08:00
|
|
|
|
|
|
|
```css
|
|
|
|
.site-input-group-wrapper .site-input-split {
|
|
|
|
background-color: #fff;
|
|
|
|
}
|
2020-03-02 12:24:24 +08:00
|
|
|
|
|
|
|
.site-input-group-wrapper .site-input-right {
|
|
|
|
border-left-width: 0;
|
|
|
|
}
|
|
|
|
|
2020-05-09 18:02:18 +08:00
|
|
|
.site-input-group-wrapper .site-input-right:hover,
|
|
|
|
.site-input-group-wrapper .site-input-right:focus {
|
2020-03-02 12:24:24 +08:00
|
|
|
border-left-width: 1px;
|
|
|
|
}
|
2020-05-01 14:50:35 +08:00
|
|
|
|
|
|
|
.site-input-group-wrapper .ant-input-rtl.site-input-right {
|
|
|
|
border-right-width: 0;
|
|
|
|
}
|
|
|
|
|
2020-05-09 18:02:18 +08:00
|
|
|
.site-input-group-wrapper .ant-input-rtl.site-input-right:hover,
|
|
|
|
.site-input-group-wrapper .ant-input-rtl.site-input-right:focus {
|
2020-05-01 14:50:35 +08:00
|
|
|
border-right-width: 1px;
|
|
|
|
}
|
2019-12-25 21:48:54 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
<style>
|
|
|
|
[data-theme="dark"] .site-input-group-wrapper .site-input-split {
|
2020-02-24 22:44:29 +08:00
|
|
|
background-color: transparent;
|
2019-12-25 21:48:54 +08:00
|
|
|
}
|
|
|
|
</style>
|