Collapse 折叠面板

通过折叠面板收纳内容区域

基础用法

可同时展开多个面板,面板之间不影响

Consistency
Consistent with real life: in line with the process and logic of real life, and comply with languages and habits that the users are used to;
Consistent within interface: all elements should be consistent, such as: design style, icons and texts, position of elements, etc.

手风琴效果

每次只能展开一个面板

通过 accordion 属性来设置是否以手风琴模式显示。

Consistency
Consistent with real life: in line with the process and logic of real life, and comply with languages and habits that the users are used to;
Consistent within interface: all elements should be consistent, such as: design style, icons and texts, position of elements, etc.

自定义面板标题

除了可以通过 title 属性以外,还可以通过具名 slot 来实现自定义面板的标题内容,以实现增加图标等效果。

TIP

从版本 2.9.10开始, title 插槽提供一个 isActive 属性,显示当前折叠项是否活跃。

自定义图标 2.8.3

除了使用 icon 属性外,您还可以自定义面板项目图标,从而添加自定义内容。

Consistency
Consistent with real life: in line with the process and logic of real life, and comply with languages and habits that the users are used to;
Consistent within interface: all elements should be consistent, such as: design style, icons and texts, position of elements, etc.

自定义图标位置 2.9.10

使用 expand-icon-position 属性,您可以自定义图标位置。

expand icon position:
left

阻止折叠 2.9.11

设置 beforeChange 属性,若返回 false 或者返回 Promise 且被 reject ,则停止切换。

before collapse return:
true
Consistency
Consistent with real life: in line with the process and logic of real life, and comply with languages and habits that the users are used to;
Consistent within interface: all elements should be consistent, such as: design style, icons and texts, position of elements, etc.

Collapse API

Collapse Attributes

属性名说明类型默认值
value当前展开的面板。手风琴模式为单值,否则为数组array / string / number[]
accordion是否手风琴模式booleanfalse
expandIconPosition展开图标位置enumright
beforeCollapse切换前钩子,返回 false 或 reject 的 Promise 阻止切换Function—
className根节点类名string—

Collapse Events

事件名说明参数
onChange展开面板变化,等价官方 changeFunction,手风琴为单值,否则为数组

Collapse Slots

插槽名说明React 写法
default折叠面板子项children

CollapseItem Attributes

属性名说明类型默认值
name面板标识,省略时用自动生成的 idstring / number—
title标题;传函数可获取 { isActive }ReactNode / Function—
disabled是否禁用booleanfalse
icon自定义图标;传节点包在官方 arrow 容器内,传函数完全接管渲染ReactNode / FunctionArrowRight
className自定义类名string—

CollapseItem Slots

插槽名说明React 写法
default面板内容children
title自定义标题,参数 { isActive }title 函数属性
icon自定义图标,参数 { isActive }icon 函数属性