mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-04 08:59:40 +08:00
7fd093bd0a
* docs: add general components TS demo * docs: add layout components TS demo * docs: add navigation components TS demo * docs: add data entry components TS demo * chore(deps): add types for qs * docs: add data display TS demo * docs: add feedback components TS demo * docs: add other components TS demo * chore(deps): add types * docs: unified demo code style * docs: fix lint error * docs: add demo TS type * docs: fix demo TS type * test: update snapshot * docs: fix TS demo * feat: update Rate character type * docs: fix lint error * feat: update Rate character type * feat: update Rate character type
1.3 KiB
1.3 KiB
order | title | ||||
---|---|---|---|---|---|
24 |
|
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.
import React, { useState } from 'react';
import { Select, Space } from 'antd';
import type { SelectProps } 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 App: React.FC = () => {
const [value, setValue] = useState(['a10', 'c12', 'h17', 'j19', 'k20']);
const selectProps: SelectProps = {
mode: 'multiple',
style: { width: '100%' },
value,
options,
onChange: (newValue: string[]) => {
setValue(newValue);
},
placeholder: 'Select Item...',
maxTagCount: 'responsive',
};
return (
<Space direction="vertical" style={{ width: '100%' }}>
<Select {...selectProps} />
<Select {...selectProps} disabled />
</Space>
);
};
export default App;