You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1005 B
40 lines
1005 B
import { Checkbox } from 'antd';
|
|
import type { CheckboxValueType } from 'antd/es/checkbox/Group';
|
|
import React from 'react';
|
|
|
|
const onChange = (checkedValues: CheckboxValueType[]) => {
|
|
console.log('checked = ', checkedValues);
|
|
};
|
|
|
|
const plainOptions = ['Apple', 'Pear', 'Orange'];
|
|
|
|
const options = [
|
|
{ label: 'Apple', value: 'Apple' },
|
|
{ label: 'Pear', value: 'Pear' },
|
|
{ label: 'Orange', value: 'Orange' },
|
|
];
|
|
|
|
const optionsWithDisabled = [
|
|
{ label: 'Apple', value: 'Apple' },
|
|
{ label: 'Pear', value: 'Pear' },
|
|
{ label: 'Orange', value: 'Orange', disabled: false },
|
|
];
|
|
|
|
const App: React.FC = () => (
|
|
<>
|
|
<Checkbox.Group options={plainOptions} defaultValue={['Apple']} onChange={onChange} />
|
|
<br />
|
|
<br />
|
|
<Checkbox.Group options={options} defaultValue={['Pear']} onChange={onChange} />
|
|
<br />
|
|
<br />
|
|
<Checkbox.Group
|
|
options={optionsWithDisabled}
|
|
disabled
|
|
defaultValue={['Apple']}
|
|
onChange={onChange}
|
|
/>
|
|
</>
|
|
);
|
|
|
|
export default App;
|
|
|