mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-16 01:29:11 +08:00
0054ff9dfd
* feat: add icon to collapsible in collapse * fix: typo * Apply suggestions from code review * test: update snapshot of collapsible.md * feat: edit api support version * feat: edit api support version * fix: reinstall modules and update snapshots Co-authored-by: yangchen7 <yangchen7@360.cn> Co-authored-by: afc163 <afc163@gmail.com>
59 lines
1.3 KiB
Markdown
59 lines
1.3 KiB
Markdown
---
|
|
order: 7
|
|
title:
|
|
zh-CN: 可折叠触发区域
|
|
en-US: Collapsible
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
通过 `collapsible` 属性,可以设置面板的可折叠触发区域。
|
|
|
|
## en-US
|
|
|
|
Specify the trigger area of collapsible by `collapsible`.
|
|
|
|
```tsx
|
|
import { Collapse, Space } from 'antd';
|
|
import React from 'react';
|
|
|
|
const { Panel } = Collapse;
|
|
|
|
const text = `
|
|
A dog is a type of domesticated animal.
|
|
Known for its loyalty and faithfulness,
|
|
it can be found as a welcome guest in many households across the world.
|
|
`;
|
|
|
|
const App: React.FC = () => (
|
|
<Space direction="vertical">
|
|
<Collapse collapsible="header" defaultActiveKey={['1']}>
|
|
<Panel header="This panel can only be collapsed by clicking text" key="1">
|
|
<p>{text}</p>
|
|
</Panel>
|
|
</Collapse>
|
|
<Collapse collapsible="icon" defaultActiveKey={['1']}>
|
|
<Panel header="This panel can only be collapsed by clicking icon" key="1">
|
|
<p>{text}</p>
|
|
</Panel>
|
|
</Collapse>
|
|
<Collapse collapsible="disabled">
|
|
<Panel header="This panel can't be collapsed" key="1">
|
|
<p>{text}</p>
|
|
</Panel>
|
|
</Collapse>
|
|
</Space>
|
|
);
|
|
|
|
export default App;
|
|
```
|
|
|
|
<style>
|
|
[data-theme="compact"] p, p {
|
|
margin: 0;
|
|
}
|
|
#components-collapse-demo-collapsible .ant-space {
|
|
width: 100%;
|
|
}
|
|
</style>
|