1# Panel 2 3The **<Panel\>** component is a slidable panel that presents lightweight content with flexible sizes. 4 5> **NOTE** 6> 7> This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version. 8 9 10## Child Components 11 12Supported 13 14> **NOTE** 15> 16> Built-in components and custom components are allowed, with support for ([if/else](../../quick-start/arkts-rendering-control-ifelse.md), [ForEach](../../quick-start/arkts-rendering-control-foreach.md), and [LazyForEach](../../quick-start/arkts-rendering-control-lazyforeach.md)) rendering control. 17 18 19## APIs 20 21Panel(show: boolean) 22 23**Parameters** 24 25| Name| Type| Mandatory| Description| 26| -------- | -------- | -------- | -------- | 27| show | boolean | Yes| Whether the panel is shown.<br>**NOTE**<br>The panel is hidden and does not take up space in the layout if this parameter is set to **false** or [Visible.None](ts-universal-attributes-visibility.md) is set.| 28 29## Attributes 30 31In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported. 32 33| Name| Type| Description| 34| -------- | -------- | -------- | 35| type | [PanelType](#paneltype)| Type of the panel.<br>Default value: **PanelType.Foldable**| 36| mode | [PanelMode](#panelmode) | Initial status of the panel.<br>Default value for the Minibar type: **PanelMode.Mini**<br/>Default value for other types: **PanelMode.Half** | 37| dragBar | boolean | Whether to enable a drag bar. The value **true** means that the drag bar will be displayed, and **false** means the opposite.<br>Default value: **true**| 38| fullHeight | string \| number | Panel height in the **PanelMode.Full** mode.<br>Default value: main axis height of the panel minus 8 vp<br>**NOTE**<br>This attribute cannot be set in percentage.| 39| halfHeight | string \| number | Panel height in the **PanelMode.Half** mode.<br>Default value: half of the main axis height of the panel<br>**NOTE**<br>This attribute cannot be set in percentage.| 40| miniHeight | string \| number | Panel height in the **PanelMode.Mini** mode.<br>Default value: **48**<br>Unit: vp<br>**NOTE**<br>This attribute cannot be set in percentage.| 41| show | boolean | Whether to show the panel.<br>Default value: **true**| 42| backgroundMask<sup>9+</sup>|[ResourceColor](ts-types.md#resourcecolor)|Background mask of the panel.<br>Default value: **'#08182431'**| 43 44## PanelType 45 46| Name| Description| 47| -------- | -------- | 48| Minibar | A minibar panel displays content in the minibar area or a large (fullscreen-like) area.| 49| Foldable | A foldable panel displays permanent content in a large (fullscreen-like), medium-sized (halfscreen-like), or small area.| 50| Temporary | A temporary panel displays content in a large (fullscreen-like) or medium-sized (halfscreen-like) area.| 51 52## PanelMode 53 54| Name| Description| 55| -------- | -------- | 56| Mini | Displays a **minibar** or **foldable** panel in its minimum size. This attribute does not take effect for **temporary** panels.| 57| Half | Displays a **foldable** or **temporary** panel in a medium-sized (halfscreen-like) area. This attribute does not take effect for **minibar** panels.| 58| Full | Displays a panel in a large (fullscreen-like) area.| 59 60## Events 61 62In addition to the [universal events](ts-universal-events-click.md), the following events are supported. 63 64| Name| Description| 65| -------- | -------- | 66| onChange(event: (width: number, height: number, mode: PanelMode) => void) | Triggered when the status of the panel changes. The returned height value is the height of the content area. When the value of **dragBar** is **true**, the panel height is the sum of the drag bar height and content area height.| 67| onHeightChange(callback: (value: number) => void)<sup>9+</sup> |Triggered when the height of the panel changes. The returned height value is the height of the content area, in px by default. When the value of **dragBar** is **true**, the panel height is the sum of the drag bar height and content area height. For user experience purposes, the panel can be slid to only this height: **fullHeight** - 8 vp.| 68 69## Example 70 71```ts 72// xxx.ets 73@Entry 74@Component 75struct PanelExample { 76 @State show: boolean = false 77 78 build() { 79 Column() { 80 Text('2021-09-30 Today Calendar: 1.afternoon......Click for details') 81 .width('90%').height(50).borderRadius(10) 82 .backgroundColor(0xFFFFFF).padding({ left: 20 }) 83 .onClick(() => { 84 this.show = !this.show 85 }) 86 Panel(this.show) { // Display the agenda. 87 Column() { 88 Text('Today Calendar') 89 Divider() 90 Text('1. afternoon 4:00 The project meeting') 91 } 92 } 93 .type(PanelType.Foldable).mode(PanelMode.Half) 94 .dragBar(true) // The drag bar is enabled by default. 95 .halfHeight(500) // The panel height is half of the screen height by default. 96 .onChange((width: number, height: number, mode: PanelMode) => { 97 console.info(`width:${width},height:${height},mode:${mode}`) 98 }) 99 }.width('100%').height('100%').backgroundColor(0xDCDCDC).padding({ top: 5 }) 100 } 101} 102``` 103 104 105