目录

Panel

The Panel component is a slidable panel that presents lightweight content with flexible sizes.

Since API version 12, this component is no longer maintained. It is recommended to use the universal attribute bindSheet instead.

This component is supported since API version 7. Newly added content in later versions is marked with a superscript to indicate the version in which it was introduced.

Child Components

Supported.

Allowed child component types: built-in and custom components, including rendering control types (if/else, ForEach, and LazyForEach).

APIs

Panel(show: boolean)

Defines a slidable panel component.

This API is supported since API version 7 and deprecated since API version 12. It is recommended to use bindSheet instead.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

Name Type Mandatory Description
show boolean Yes

Whether to show or hide the panel. The value true means to show the panel, and false means to hide the panel.

NOTE

If this parameter is set to false, the panel is hidden without occupying space. When either Visibility.None or show takes effect, the panel is hidden without occupying space.

The show attribute has a higher priority than this parameter. When the show attribute is set, this parameter may not take effect.

Attributes

In addition to the universal attributes, the following attributes are supported.

[h2]type

type(value: PanelType)

Sets the type of the slidable panel. The value of the type attribute constrains the use of other attributes: when type is Minibar, PanelMode.Half does not take effect; when type is Temporary, PanelMode.Mini does not take effect; when type is CUSTOM, the size switching effect is not supported and the customHeight attribute must be used; when type is Foldable, all PanelMode values are available, and the fullHeight, halfHeight, and miniHeight attributes can be used to set the height of each state.

This API is supported since API version 7 and deprecated since API version 12. It is recommended to use preferType in SheetOptions instead.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

Name Type Mandatory Description
value PanelType Yes

Type of the slidable panel.

Default value: PanelType.Foldable

[h2]mode

mode(value: PanelMode)

Sets the initial mode of the panel.

This API is supported since API version 7 and deprecated since API version 12. It is recommended to use preferType in SheetOptions instead.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

Name Type Mandatory Description
value PanelMode Yes

Initial state of the slidable panel.

Default value for the Minibar type: PanelMode.Mini; default value for other types: PanelMode.Half

Since API version 10, this attribute supports two-way binding with variables through $$.

[h2]dragBar

dragBar(value: boolean)

Sets whether to enable a drag bar.

This API is supported since API version 7 and deprecated since API version 12. Recommended alternative: dragBar in SheetOptions.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

Name Type Mandatory Description
value boolean Yes

Whether a control bar exists. The value true indicates that a control bar exists, and false indicates the opposite.

Default value: true

[h2]customHeight10+

customHeight(value: Dimension | PanelHeight)

Sets the height in the PanelType.CUSTOM state. This attribute only takes effect when type is set to PanelType.CUSTOM. When PanelHeight.WRAP_CONTENT is used, the height adapts to the content; when a Dimension value is used, a fixed height is set.

This API is supported since API version 10 and deprecated since API version 12. Recommended alternative: height in SheetOptions.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

Name Type Mandatory Description
value Dimension | PanelHeight Yes

Height in the PanelType.CUSTOM state.

Default value: 0

Note:

It does not support setting percentage. It does not take effect when a percentage is passed in. It does not take effect when a negative number is passed in.

[h2]fullHeight

fullHeight(value: number | string)

Sets the height in the PanelMode.Full state.

This API is supported since API version 7 and deprecated since API version 12. Recommended alternative: height in SheetOptions.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

Name Type Mandatory Description
value number | string Yes

Height in the PanelMode.Full state.

Default value: the current component's main axis size minus an 8 vp blank area

Unit: vp

Note:

It does not support setting percentage.

[h2]halfHeight

halfHeight(value: number | string)

Sets the height of the panel in PanelMode.Half mode.

This attribute takes effect only when type is Foldable or Temporary. When type is Minibar, the Half mode does not take effect, and halfHeight is invalid.

This API is supported since API version 7 and deprecated since API version 12. Recommended alternative: height in SheetOptions.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

Name Type Mandatory Description
value number | string Yes

Height in the PanelMode.Half state.

Default value: half of the main axis size of the current component.

Unit: vp

Note:

Does not support setting percentage.

[h2]miniHeight

miniHeight(value: number | string)

Sets the height of the panel in the PanelMode.Mini mode.

This attribute takes effect only when type is Minibar or Foldable. When type is Temporary, the Mini mode does not take effect, and miniHeight is invalid.

This API is supported since API version 7 and deprecated since API version 12. Recommended alternative: height in SheetOptions.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

Name Type Mandatory Description
value number | string Yes

Height in the PanelMode.Mini state.

Default value: 48

Unit: vp

Note:

Does not support setting percentage.

[h2]show

show(value: boolean)

Set whether to show the panel.

This API is supported since API version 7 and deprecated since API version 12. Recommended alternative: isShow in SheetOptions.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

Name Type Mandatory Description
value boolean Yes

Whether to show the panel. The value true means to display the panel, and false means not to display the panel.

Default value: true

Note:

This attribute has a higher priority than the show parameter.

[h2]backgroundMask9+

backgroundMask(color: ResourceColor)

Set the background mask of the panel.

This API is supported since API version 9 and deprecated since API version 12. Recommended alternative: maskColor in SheetOptions.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

Name Type Mandatory Description
color ResourceColor Yes

Background mask of the panel.

Default value: '#08182431'

[h2]showCloseIcon10+

showCloseIcon(value: boolean)

Sets whether to display the close icon.

This API is supported since API version 10 and deprecated since API version 12. Recommended alternative: showClose in SheetOptions.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

Name Type Mandatory Description
value boolean Yes

Whether to display the close icon. The value true indicates display, and false indicates not display.

Default value: false

PanelType

This API is supported since API version 7 and deprecated since API version 12. Recommended alternative: SheetSize.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Name Value Description
Minibar 0 Provides the switching effect between the minibar and full-screen-like display.
Foldable 1 The content is always displayed, providing the switching effect among three sizes: large (full-screen-like), medium (half-screen-like), and small.
Temporary 2 The content is displayed temporarily, providing the switching effect between two sizes: large (full-screen-like) and medium (half-screen-like).
CUSTOM10+ 3 Configures the adaptive content height and does not support the size switching effect.

PanelMode

This API is supported since API version 7 and deprecated since API version 12.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Name Value Description
Mini 0 When the type is Minibar or Foldable, the panel is in the minimum state. When the type is Temporary, this does not take effect.
Half 1 When the type is Foldable or Temporary, the panel is in the half-screen-like state. When the type is Minibar, this does not take effect.
Full 2 When the type is Minibar, Foldable, or Temporary, the panel is in the full-screen-like state. When the type is CUSTOM, this does not take effect.

PanelHeight10+

This API is supported since API version 10 and deprecated since API version 12. Recommended alternative: SheetSize.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Name Value Description
WRAP_CONTENT 'wrapContent' When the type of PanelType is CUSTOM, the height adapts to the content.

Events

In addition to the universal events, the following events are supported.

[h2]onChange

onChange(event: (width: number, height: number, mode: PanelMode) => void)

Triggered when the status of the slidable panel changes. Difference from onHeightChange: onChange is triggered when the panel mode switches, and returns the width, height, and mode information; onHeightChange is triggered when the panel height changes, and returns only the height value. Use onChange when you need to detect mode switching, and use onHeightChange when you only need to detect height changes.

This API is supported since API version 7 and deprecated since API version 12. Recommended alternative: onTypeDidChange in SheetOptions.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

Name Type Mandatory Description
width number Yes Width of the content area, in vp.
height number Yes

Height value of the content area, in vp.

When the dragBar attribute is set to true, the height of the panel itself is the sum of the drag bar height and the content area height.

mode PanelMode Yes State of the panel.

[h2]onHeightChange9+

onHeightChange(callback: (value: number) => void)

Triggered when the height of the panel changes.

This API is supported since API version 9 and deprecated since API version 12. Recommended alternative: onHeightDidChange in SheetOptions.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

Name Type Mandatory Description
value number Yes

Height value of the content area. The default unit of the return value is px.

When the dragBar attribute is set to true, the height of the Panel itself is the dragBar height plus the content area height.

For user experience design reasons, the Panel can slide up to fullHeight - 8vp at most.

Examples

// xxx.ets
@Entry
@Component
struct PanelExample {
  @State show: boolean = false

  build() {
    Column() {
      Text('2021-09-30    Today Calendar: 1.afternoon......Click for details')
        .width('90%')
        .height(50)
        .borderRadius(10)
        .backgroundColor(0xFFFFFF)
        .padding({ left: 20 })
        .onClick(() => {
          this.show = !this.show;
        })
      Panel(this.show) { // Display calendar events.
        Column() {
          Text('Today Calendar')
          Divider()
          Text('1. afternoon 4:00 The project meeting')
        }
      }
      .type(PanelType.Foldable)
      .mode(PanelMode.Half)
      .dragBar(true) // The drag bar is enabled by default.
      .halfHeight(500) // Set the half screen height to 500. The default is half the size of the current component's main axis.
      .showCloseIcon(true) // Display the close icon.
      .onChange((width: number, height: number, mode: PanelMode) => {
        console.info(`width:${width},height:${height},mode:${mode}`);
      })
    }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 })
  }
}