mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-15 08:59:15 +08:00
ff231ab557
* feat: remove optioLabelProp * feat: doc * feat: doc * feat: option-render * feat: option-render * feat: snap
56 lines
1.0 KiB
TypeScript
56 lines
1.0 KiB
TypeScript
import React from 'react';
|
|
import type { SelectProps } from 'antd';
|
|
import { Select, Space } from 'antd';
|
|
|
|
const handleChange = (value: string[]) => {
|
|
console.log(`selected ${value}`);
|
|
};
|
|
|
|
const options: SelectProps['options'] = [
|
|
{
|
|
label: 'China',
|
|
value: 'china',
|
|
emoji: '🇨🇳',
|
|
desc: 'China (中国)',
|
|
},
|
|
{
|
|
label: 'USA',
|
|
value: 'usa',
|
|
emoji: '🇺🇸',
|
|
desc: 'USA (美国)',
|
|
},
|
|
{
|
|
label: 'Japan',
|
|
value: 'japan',
|
|
emoji: '🇯🇵',
|
|
desc: 'Japan (日本)',
|
|
},
|
|
{
|
|
label: 'Korea',
|
|
value: 'korea',
|
|
emoji: '🇰🇷',
|
|
desc: 'Korea (韩国)',
|
|
},
|
|
];
|
|
|
|
const App: React.FC = () => (
|
|
<Select
|
|
mode="multiple"
|
|
style={{ width: '100%' }}
|
|
placeholder="select one country"
|
|
defaultValue={['china']}
|
|
onChange={handleChange}
|
|
options={options}
|
|
optionRender={(option) => (
|
|
<Space>
|
|
<span role="img" aria-label={option.data.label}>
|
|
{option.data.emoji}
|
|
</span>
|
|
{option.data.desc}
|
|
</Space>
|
|
)}
|
|
/>
|
|
);
|
|
|
|
export default App;
|