Skip to content

FoldingPanel Collapse Panel Component ​

Use collapse panels to organize content areas.

📌 Platform Differences ​

APP(vue)H5WeChat Mini ProgramAlipay Mini Program
✔✔✔✔

🏯 Basic Usage Example ​

Note

index is required; it is the index

html
<hy-folding-panel v-model="activeIndex">
    <hy-folding-panel-item title="水果" index="fruits"></hy-folding-panel-item>
    <hy-folding-panel-item title="饮品" index="beverage"></hy-folding-panel-item>
</hy-folding-panel>

Disabling Panels ​

  • Disable all panels by setting disabled on hy-folding-panel
  • Disable a single panel by setting disabled on hy-folding-panel-item
html
<hy-folding-panel v-model="activeIndex" :disabled="true">
    <hy-folding-panel-item title="水果" index="fruits"></hy-folding-panel-item>
    <hy-folding-panel-item title="饮品" index="beverage"></hy-folding-panel-item>
</hy-folding-panel>

Showing Borders ​

  • Set the border via border
html
<hy-folding-panel v-model="activeIndex" :border="true">
    <hy-folding-panel-item title="水果" index="fruits"></hy-folding-panel-item>
    <hy-folding-panel-item title="饮品" index="beverage"></hy-folding-panel-item>
</hy-folding-panel>

Setting Panel Size ​

  • Set the panel size via size
    • small - small panel
    • medium - medium panel (default)
    • large - large panel
html
<hy-folding-panel v-model="activeIndex" size="small">
    <hy-folding-panel-item title="水果" index="fruits"></hy-folding-panel-item>
    <hy-folding-panel-item title="饮品" index="beverage"></hy-folding-panel-item>
</hy-folding-panel>

Custom Panel Header ​

html
<hy-folding-panel v-model="activeIndex" :disabled="true">
    <hy-folding-panel-item index="fruits">
        <template #header>
            <view class="hy-folding-panel-item__title">自定义头部</view>
        </template>
    </hy-folding-panel-item>
    <hy-folding-panel-item index="beverage">
        <template #title>
            <view class="hy-folding-panel-item__title">自定义标题</view>
        </template>
    </hy-folding-panel-item>
</hy-folding-panel>

API ​

FoldingPanel Props ​

ParameterDescriptionTypeDefault Value
modelValueCurrently active panel index, supports v-modelnumber|string-1
accordionWhether accordion mode is enabledbooleanfalse
disabledWhether the entire collapse panel group is disabledbooleanfalse
borderWhether to show the borderbooleantrue
sizePanel header sizelarge|medium|smallmedium

FoldingPanelItem Props ​

ParameterDescriptionTypeDefault Value
indexPanel index (automatically set by parent component)number|string-1
titlePanel titlestring-
valueValue displayed on the rightstring-
iconLeft iconstring-
iconColorLeft icon colorstring-
iconSizeLeft icon size, numbers default to px unitstring|numner-
contentPanel contentstring-
contentHeightMaximum height of the content area, numbers default to px unitstring|numner150
disabledWhether a single panel is disabledbooleanfalse
defaultOpenWhether expanded by defaultbooleanfalse
customStyleCustom external styles to be appliedCSSProperties-

Events ​

FoldingPanel Emits ​

Event NameDescriptionCallback Parameters
changeTriggered when panel state changesexpanded: internal expanded state, index: index
openTriggered when a panel opensindex: index
closeTriggered when a panel closesindex: index

FoldingPanelItem Emits ​

Event NameDescriptionCallback Parameters
clickChanges the panel open/close stateindex: index
changeTriggered when panel state changesexpanded: internal expanded state, index: index
openTriggered when a panel opensindex: index
closeTriggered when a panel closesindex: index
child-clickNotifies parent when a child item is clickedindex: index

Methods ​

FoldingPanel Expose ​

NameDescriptionParameters
openOpens the panel at the specified indexindex: number|string
closeCloses the panel at the specified indexindex: number|string
toggleToggles the state of the panel at the specified indexindex: number|string
closeAllCloses all panels-

FoldingPanelItem Expose ​

NameDescriptionParameters
openOpens the panel-
closeCloses the panel-
toggleToggles the panel state-
getExpandedGets the current expanded state-

Slots ​

Slot NameDescriptionReceived Values
defaultContent of the main body-
headerPanel header-
titleLeft content of the panel header-

CSS Variables ​

Variable NameDescriptionDefault Value
--hy-folding-panel-value-font-sizeRight value font size13px
--hy-folding-panel-value-margin-rightRight value right margin8px
--hy-folding-panel-font-size-largelarge title font sizeFollows --hy-font-size-lg (36rpx)
--hy-folding-panel-font-size-mediummedium title font sizeFollows --hy-font-size-base (28rpx)
--hy-folding-panel-font-size-smallsmall title font sizeFollows --hy-font-size-sm (24rpx)
--hy-folding-panel-borderPanel bottom divider lineFollows --hy-border-line
--hy-folding-panel-value-colorRight value text colorFollows --hy-text-color--grey
12:33
battery