mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import React from 'react';
|
|
import { Checkbox } from 'antd';
|
|
import type { CheckboxOptionType, GetProp } from 'antd';
|
|
|
|
const onChange: GetProp<typeof Checkbox.Group, 'onChange'> = (checkedValues) => {
|
|
console.log('checked = ', checkedValues);
|
|
};
|
|
|
|
const plainOptions = ['Apple', 'Pear', 'Orange'];
|
|
|
|
const options: CheckboxOptionType<string>[] = [
|
|
{ label: 'Apple', value: 'Apple', className: 'label-1' },
|
|
{ label: 'Pear', value: 'Pear', className: 'label-2' },
|
|
{ label: 'Orange', value: 'Orange', className: 'label-3' },
|
|
];
|
|
|
|
const optionsWithDisabled: CheckboxOptionType<string>[] = [
|
|
{ label: 'Apple', value: 'Apple', className: 'label-1' },
|
|
{ label: 'Pear', value: 'Pear', className: 'label-2' },
|
|
{ label: 'Orange', value: 'Orange', className: 'label-3', 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;
|