2017-03-03 22:10:21 +08:00
---
order: 4
title:
zh-CN: 查询模式 - 确定类目
en-US: Lookup-Patterns - Certain Category
---
## zh-CN
[查询模式: 确定类目 ](https://ant.design/docs/spec/reaction#Lookup-Patterns ) 示例。
## en-US
2019-09-12 20:15:17 +08:00
Demonstration of [Lookup Patterns: Certain Category ](https://ant.design/docs/spec/reaction#Lookup-Patterns ). Basic Usage, set options of autocomplete with `options` property.
2017-03-03 22:10:21 +08:00
2019-09-12 20:15:17 +08:00
```tsx
2019-08-13 14:07:17 +08:00
import { Input, AutoComplete } from 'antd';
2019-11-28 12:34:33 +08:00
import { SearchOutlined, UserOutlined } from '@ant-design/icons';
2018-06-27 15:55:04 +08:00
2019-05-27 21:32:45 +08:00
const { Option, OptGroup } = AutoComplete;
2017-03-03 22:10:21 +08:00
2019-09-12 20:15:17 +08:00
function renderTitle(title: string) {
2017-03-06 17:56:34 +08:00
return (
< span >
{title}
< a
style={{ float: 'right' }}
href="https://www.google.com/search?q=antd"
target="_blank"
rel="noopener noreferrer"
2019-05-07 14:57:32 +08:00
>
2019-06-11 13:07:58 +08:00
more
2017-03-06 17:56:34 +08:00
< / a >
< / span >
);
2017-03-03 22:10:21 +08:00
}
2019-09-12 20:15:17 +08:00
function renderItem(title: string, count: number) {
return {
value: title,
label: (
< >
{title}
< span className = "certain-search-item-count" >
2019-11-28 12:34:33 +08:00
< UserOutlined / > {count}
2019-09-12 20:15:17 +08:00
< / span >
< />
),
};
}
const options = [
{
label: renderTitle('Libraries'),
options: [renderItem('AntDesign', 10000), renderItem('AntDesign UI', 10600)],
},
{
label: renderTitle('Solutions'),
options: [renderItem('AntDesign UI FAQ', 60100), renderItem('AntDesign FAQ', 30010)],
},
{
label: renderTitle('Articles'),
options: [renderItem('AntDesign design language', 100000)],
},
];
2017-03-03 22:10:21 +08:00
function Complete() {
return (
< div className = "certain-category-search-wrapper" style = {{ width: 250 } } >
< AutoComplete
className="certain-category-search"
dropdownClassName="certain-category-search-dropdown"
2019-09-12 20:15:17 +08:00
dropdownMatchSelectWidth={500}
2017-03-03 22:10:21 +08:00
style={{ width: '100%' }}
2019-09-12 20:15:17 +08:00
options={options}
2017-03-03 22:10:21 +08:00
>
2019-09-12 20:15:17 +08:00
< Input
size="large"
2019-11-28 12:34:33 +08:00
suffix={< SearchOutlined className = "certain-category-icon" / > }
2019-09-12 20:15:17 +08:00
placeholder="input here"
/>
2017-03-03 22:10:21 +08:00
< / AutoComplete >
< / div >
);
}
ReactDOM.render(< Complete / > , mountNode);
2019-05-07 14:57:32 +08:00
```
2017-03-03 22:10:21 +08:00
2019-05-07 14:57:32 +08:00
```css
2017-03-18 21:26:42 +08:00
.certain-category-search.ant-select-auto-complete .ant-input-affix-wrapper .ant-input-suffix {
2017-03-06 17:56:34 +08:00
right: 12px;
2017-03-03 22:10:21 +08:00
}
.certain-category-search-dropdown .ant-select-dropdown-menu-item-group-title {
color: #666 ;
font-weight: bold;
}
.certain-category-search-dropdown .ant-select-dropdown-menu-item-group {
2019-05-07 14:57:32 +08:00
border-bottom: 1px solid #f6f6f6 ;
2017-03-03 22:10:21 +08:00
}
.certain-category-search-dropdown .ant-select-dropdown-menu-item {
padding-left: 16px;
}
.certain-category-search-dropdown .ant-select-dropdown-menu-item.show-all {
text-align: center;
cursor: default;
}
.certain-category-search-dropdown .ant-select-dropdown-menu {
max-height: 300px;
}
.certain-search-item-count {
2019-05-07 14:57:32 +08:00
position: absolute;
color: #999 ;
right: 16px;
2017-03-03 22:10:21 +08:00
}
.certain-category-search.ant-select-focused .certain-category-icon {
2017-03-06 17:56:34 +08:00
color: #108ee9 ;
2017-03-03 22:10:21 +08:00
}
.certain-category-icon {
2019-05-07 14:57:32 +08:00
color: #6e6e6e ;
2017-03-03 22:10:21 +08:00
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
font-size: 16px;
}
2019-05-07 14:57:32 +08:00
```