mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-02 15:59:38 +08:00
6ecfa74e7d
* feat: init select overflow * chore: use inline-xxx instead of rtl * docs: Add demo * test: Update snapshot * fix: style lint * test: Update snapshot * chore: Update rc-tree-select version * test: Update snapshot * test: Update snapshot * chore: bump all rc-resize-observer version * bump bundle size
59 lines
1.2 KiB
Markdown
59 lines
1.2 KiB
Markdown
---
|
|
order: 24
|
|
title:
|
|
zh-CN: 响应式 maxTagCount
|
|
en-US: Responsive maxTagCount
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
多选下通过响应式布局让选项自动收缩。该功能对性能有所消耗,不推荐在大表单场景下使用。
|
|
|
|
## en-US
|
|
|
|
Auto collapse to tag with responsive case. Not recommend use in large form case since responsive calculation has a perf cost.
|
|
|
|
```tsx
|
|
import { Select, Space } from 'antd';
|
|
|
|
interface ItemProps {
|
|
label: string;
|
|
value: string;
|
|
}
|
|
|
|
const options: ItemProps[] = [];
|
|
|
|
for (let i = 10; i < 36; i++) {
|
|
const value = i.toString(36) + i;
|
|
options.push({
|
|
label: `Long Label: ${value}`,
|
|
value,
|
|
});
|
|
}
|
|
|
|
const Demo = () => {
|
|
const [value, setValue] = React.useState(['a10', 'c12', 'h17', 'j19', 'k20']);
|
|
|
|
const selectProps = {
|
|
mode: 'multiple' as const,
|
|
style: { width: '100%' },
|
|
value,
|
|
options,
|
|
onChange: (newValue: string[]) => {
|
|
setValue(newValue);
|
|
},
|
|
placeholder: 'Select Item...',
|
|
maxTagCount: 'responsive' as const,
|
|
};
|
|
|
|
return (
|
|
<Space direction="vertical" style={{ width: '100%' }}>
|
|
<Select {...selectProps} />
|
|
<Select {...selectProps} disabled />
|
|
</Space>
|
|
);
|
|
};
|
|
|
|
ReactDOM.render(<Demo />, mountNode);
|
|
```
|