ant-design/components/checkbox/demo/layout.md

49 lines
1.0 KiB
Markdown
Raw Normal View History

---
order: 5
title:
zh-CN: 布局
en-US: Use with Grid
---
## zh-CN
Checkbox.Group 内嵌 Checkbox 并与 Grid 组件一起使用,可以实现灵活的布局。
## en-US
We can use Checkbox and Grid in Checkbox.Group, to implement complex layout.
```tsx
2022-05-21 22:14:15 +08:00
import { Checkbox, Col, Row } from 'antd';
import type { CheckboxValueType } from 'antd/es/checkbox/Group';
2022-05-21 22:14:15 +08:00
import React from 'react';
const onChange = (checkedValues: CheckboxValueType[]) => {
console.log('checked = ', checkedValues);
};
const App: React.FC = () => (
<Checkbox.Group style={{ width: '100%' }} onChange={onChange}>
<Row>
2019-05-07 14:57:32 +08:00
<Col span={8}>
<Checkbox value="A">A</Checkbox>
</Col>
<Col span={8}>
<Checkbox value="B">B</Checkbox>
</Col>
<Col span={8}>
<Checkbox value="C">C</Checkbox>
</Col>
<Col span={8}>
<Checkbox value="D">D</Checkbox>
</Col>
<Col span={8}>
<Checkbox value="E">E</Checkbox>
</Col>
</Row>
</Checkbox.Group>
);
export default App;
2019-05-07 14:57:32 +08:00
```