import React from 'react';
import { Collapse } from '@douyinfe/semi-ui';
() => (
<Collapse>
<Collapse.Panel header="This is panel header 1" itemKey="1">
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
</Collapse.Panel>
<Collapse.Panel header="This is panel header 2" itemKey="2">
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
</Collapse.Panel>
<Collapse.Panel header="This is panel header 3" itemKey="3">
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
</Collapse.Panel>
</Collapse>
);
手风琴效果
可以通过设置 accordion 使每次只允许展开一个面板。
import React from 'react';
import { Collapse } from '@douyinfe/semi-ui';
() => (
<Collapse accordion>
<Collapse.Panel header="This is panel header 1" itemKey="1">
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
</Collapse.Panel>
<Collapse.Panel header="This is panel header 2" itemKey="2">
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
</Collapse.Panel>
<Collapse.Panel header="This is panel header 3" itemKey="3">
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
</Collapse.Panel>
</Collapse>
);
禁用面板
可以通过设置 disabled 禁用面板。
import React from 'react';
import { Collapse } from '@douyinfe/semi-ui';
() => (
<Collapse accordion>
<Collapse.Panel header="This is panel header 1" itemKey="1" disabled>
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
</Collapse.Panel>
<Collapse.Panel header="This is panel header 2" itemKey="2">
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
</Collapse.Panel>
<Collapse.Panel header="This is panel header 3" itemKey="3">
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
</Collapse.Panel>
</Collapse>
);
隐藏面板展开/收起图标
可以通过设置 showArrow 隐藏面板展开/收起图标。
import React from 'react';
import { Collapse } from '@douyinfe/semi-ui';
() => (
<Collapse accordion>
<Collapse.Panel header="This is panel header 1" itemKey="1" showArrow={false}>
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
</Collapse.Panel>
<Collapse.Panel header="This is panel header 2" itemKey="2">
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
</Collapse.Panel>
<Collapse.Panel header="This is panel header 3" itemKey="3">
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
</Collapse.Panel>
</Collapse>
);
自定义展开图标
可以通过 expandIcon 设置展开图标,collapseIcon 设置折叠图标。
import React from 'react';
import { Collapse } from '@douyinfe/semi-ui';
import { IconPlus, IconMinus } from '@douyinfe/semi-icons';
() => (
<Collapse expandIcon={<IconPlus />} collapseIcon={<IconMinus />}>
<Collapse.Panel header="This is panel header 1" itemKey="1">
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
</Collapse.Panel>
<Collapse.Panel header="This is panel header 2" itemKey="2">
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
</Collapse.Panel>
<Collapse.Panel header="This is panel header 3" itemKey="3">
<p>Hi, bytedance dance dance. This is the docsite of Semi UI. </p>
</Collapse.Panel>
</Collapse>
);