mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 09:21:22 +08:00
c17b40ae70
* fix: comment and input * fix: add @pagination-item-input-bg * feat: add @list-customize-card-bg for dark hook component * feat: add dark hook * fix: checkbox color * fix: popover-customize-border-color * fix: table * fix: style lint * fix: debug * fix: color * fix: update colors * fix: demo * feat: popover container bg use mixins utils * fix: less dark * fix: table bg in dark * fix: fixed table * fix: lint * fix: lint * feat: add @table-expand-icon-bg * fix: notification bg * fix: remove dark.md * fix: dropdown * fix: table * fix: data lint * fix: style * fix: dark less style * fix: @steps-background * fix: add thead dark style * fix: unused styles
4.8 KiB
4.8 KiB
order | title | ||||
---|---|---|---|---|---|
3 |
|
zh-CN
输入框的组合展现。
注意:使用 compact
模式时,不需要通过 Col
来控制宽度。
en-US
Input.Group example
Note: You don't need Col
to control the width in the compact
mode.
import { Input, Col, Row, Select, InputNumber, DatePicker, AutoComplete, Cascader } from 'antd';
const InputGroup = Input.Group;
const { Option } = Select;
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',
},
],
},
],
},
];
class CompactDemo extends React.Component {
state = {
dataSource: [],
};
handleChange = value => {
this.setState({
dataSource:
!value || value.indexOf('@') >= 0
? []
: [`${value}@gmail.com`, `${value}@163.com`, `${value}@qq.com`],
});
};
render() {
return (
<div className="site-input-group-wrapper">
<InputGroup size="large">
<Row gutter={8}>
<Col span={5}>
<Input defaultValue="0571" />
</Col>
<Col span={8}>
<Input defaultValue="26888888" />
</Col>
</Row>
</InputGroup>
<br />
<InputGroup compact>
<Input style={{ width: '20%' }} defaultValue="0571" />
<Input style={{ width: '30%' }} defaultValue="26888888" />
</InputGroup>
<br />
<InputGroup compact>
<Select defaultValue="Zhejiang">
<Option value="Zhejiang">Zhejiang</Option>
<Option value="Jiangsu">Jiangsu</Option>
</Select>
<Input style={{ width: '50%' }} defaultValue="Xihu District, Hangzhou" />
</InputGroup>
<br />
<InputGroup compact>
<Select defaultValue="Option1">
<Option value="Option1">Option1</Option>
<Option value="Option2">Option2</Option>
</Select>
<Input style={{ width: '50%' }} defaultValue="input content" />
<InputNumber />
</InputGroup>
<br />
<InputGroup compact>
<Input style={{ width: '50%' }} defaultValue="input content" />
<DatePicker style={{ width: '50%' }} />
</InputGroup>
<br />
<InputGroup 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>
</InputGroup>
<br />
<InputGroup 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 style={{ width: 100, textAlign: 'center', borderLeft: 0 }} placeholder="Maximum" />
</InputGroup>
<br />
<InputGroup compact>
<Select defaultValue="Sign Up">
<Option value="Sign Up">Sign Up</Option>
<Option value="Sign In">Sign In</Option>
</Select>
<AutoComplete
dataSource={this.state.dataSource}
style={{ width: 200 }}
onChange={this.handleChange}
placeholder="Email"
/>
</InputGroup>
<br />
<InputGroup 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" />
</InputGroup>
</div>
);
}
}
ReactDOM.render(<CompactDemo />, mountNode);
.site-input-group-wrapper .site-input-split {
background-color: #fff;
}