ant-design/components/select/demo/option-render.tsx
MadCcc a5d308b408
feat: select sort support search (#49352)
* feat: select filter support sort param

* docs: update demo to fix lint

---------

Co-authored-by: 闲夕 <shizexian.szx@antgroup.com>
2024-06-21 09:52:07 +08:00

55 lines
999 B
TypeScript

import React from 'react';
import { Select, Space } from 'antd';
const handleChange = (value: string[]) => {
console.log(`selected ${value}`);
};
const 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;