1e41f4b71Sopenharmony_ci# panel
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci>  **NOTE**
4e41f4b71Sopenharmony_ci>
5e41f4b71Sopenharmony_ci>  This component is supported since API version 5. Updates will be marked with a superscript to indicate their earliest API version.
6e41f4b71Sopenharmony_ci
7e41f4b71Sopenharmony_ciThe **\<panel>** component is a slidable, pop-up component that provides a lightweight content display window with flexible sizes.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Child Components
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ciSupported
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci## Attributes
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciIn addition to the [universal attributes](js-components-common-attributes.md), the following attributes are supported.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci| Name        | Type            | Default Value     | Mandatory  | Description                                      |
20e41f4b71Sopenharmony_ci| ---------- | -------------- | -------- | ---- | ---------------------------------------- |
21e41f4b71Sopenharmony_ci| type       | string         | foldable | Yes   | Type of the slidable panel. This attribute cannot be dynamically changed. Available values are as follows:<br>- **minibar**: A minibar panel displays content in the minibar area or a large (fullscreen-like) area.<br>- **foldable**: A foldable panel displays permanent content in a large (fullscreen-like), medium-sized (halfscreen-like), or small area.<br>- **temporary**: A temporary panel displays content in a large (fullscreen-like) or medium-sized (halfscreen-like) area.|
22e41f4b71Sopenharmony_ci| mode       | string         | full     | No   | Initial status of the slidable panel. Available values are as follows:<br>1. **mini**: Displays a **minibar** or **foldable** panel in its minimum size. This attribute does not take effect for **temporary** panels.<br>2. **half**: Displays a **foldable** or **temporary** panel in a medium-sized (halfscreen-like) area. This attribute does not take effect for **minibar** panels.<br>3. **full**: Displays a panel in a large (fullscreen-like) area.|
23e41f4b71Sopenharmony_ci| dragbar    | boolean        | true     | No   | Whether to enable a drag bar. The value **true** means that the drag bar will be displayed, and **false** means the opposite.      |
24e41f4b71Sopenharmony_ci| fullheight | &lt;length&gt; | -        | No   | Panel height in the **full** mode. The default value is the screen height minus 8 px.   |
25e41f4b71Sopenharmony_ci| halfheight | &lt;length&gt; | -        | No   | Panel height in the **half** mode. The default value is half of the screen height.                |
26e41f4b71Sopenharmony_ci| miniheight | &lt;length&gt; | -        | No   | Panel height in the **mini** mode. The default value is **48px**.                   |
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci>  **NOTE**
29e41f4b71Sopenharmony_ci>  - Rendering attributes, including **for**, **if**, and **show**, are not supported.
30e41f4b71Sopenharmony_ci>
31e41f4b71Sopenharmony_ci>  - The **focusable** and **disabled** attributes are not supported.
32e41f4b71Sopenharmony_ci
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci## Styles
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ciOnly the following styles are supported.
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ci| Name                                      | Type                                      | Default Value         | Mandatory  | Description                                      |
39e41f4b71Sopenharmony_ci| ---------------------------------------- | ---------------------------------------- | ------------ | ---- | ---------------------------------------- |
40e41f4b71Sopenharmony_ci| padding                                  | &lt;length&gt;                           | 0            | No   | The attribute can have one to four values:<br>- If you set only one value, it specifies the padding for all the four sides.<br>- If you set two values, the first value specifies the top and bottom padding, and the second value specifies the left and right padding.<br>- If you set three values, the first value specifies the top padding, the second value specifies the left and right padding, and the third value specifies the bottom padding.<br>- If you set four values, they respectively specify the padding for top, right, bottom, and left sides (in clockwise order).|
41e41f4b71Sopenharmony_ci| padding-[left\|top\|right\|bottom]       | &lt;length&gt;                           | 0            | No   | Left, top, right, and bottom padding.                         |
42e41f4b71Sopenharmony_ci| padding-[start\|end]                     | &lt;length&gt;                           | 0            | No   | Start and end padding.                           |
43e41f4b71Sopenharmony_ci| margin                                   | &lt;length&gt;                           | 0            | No   | Shorthand attribute to set the margin for all sides in a declaration. The attribute can have one to four values:<br>- If you set only one value, it specifies the margin for all the four sides.<br>- If you set two values, the first value specifies the top and bottom margins, and the second value specifies the left and right margins.<br>- If you set three values, the first value specifies the top margin, the second value specifies the left and right margins, and the third value specifies the bottom margin.<br>- If you set four values, they respectively specify the margin for top, right, bottom, and left sides (in clockwise order).|
44e41f4b71Sopenharmony_ci| margin-[left\|top\|right\|bottom]        | &lt;length&gt;                           | 0            | No   | Left, top, right, and bottom margins.                         |
45e41f4b71Sopenharmony_ci| margin-[start\|end]                      | &lt;length&gt;                           | 0            | No   | Start and end margins.                           |
46e41f4b71Sopenharmony_ci| border                                   | -                                        | 0            | No   | Shorthand attribute to set all borders. Set **border-width**, **border-style**, and **border-color** in sequence. Default values are used for attributes that are not set.|
47e41f4b71Sopenharmony_ci| border-style                             | string                                   | solid        | No   | Shorthand attribute to set the style for all borders. Available values are as follows:<br>- **dotted**: dotted border. The radius of a dot is half of **border-width**.<br>- **dashed**: dashed border.<br>- **solid**: solid border.|
48e41f4b71Sopenharmony_ci| border-[left\|top\|right\|bottom]-style  | string                                   | solid        | No   | Styles of the left, top, right, and bottom borders. The available values are **dotted**, **dashed**, and **solid**.|
49e41f4b71Sopenharmony_ci| border-[left\|top\|right\|bottom]        | -                                        | -            | No   | Shorthand attribute to set the borders for every side respectively. Set **border-width**, **border-style**, and **border-color** in sequence. Default values are used for attributes that are not set.|
50e41f4b71Sopenharmony_ci| border-width                             | &lt;length&gt;                           | 0            | No   | Shorthand attribute to set the width for all borders, or separately set the width for each border.        |
51e41f4b71Sopenharmony_ci| border-[left\|top\|right\|bottom]-width  | &lt;length&gt;                           | 0            | No   | Attribute to set widths of left, top, right, and bottom borders.                     |
52e41f4b71Sopenharmony_ci| border-color                             | &lt;color&gt;                            | black        | No   | Shorthand attribute to set the color for all borders, or separately set the color for each border.        |
53e41f4b71Sopenharmony_ci| border-[left\|top\|right\|bottom]-color  | &lt;color&gt;                            | black        | No   | Attribute to set colors for left, top, right, and bottom borders.                     |
54e41f4b71Sopenharmony_ci| border-radius                            | &lt;length&gt;                           | -            | No   | Attribute to set the radius of round-corner borders. This attribute cannot be used to set the width or color of a specific border. To set the width or color, you must set **border-width** or **border-color** for all the borders at the same time. |
55e41f4b71Sopenharmony_ci| border-[top\|bottom]-[left\|right]-radius | &lt;length&gt;                           | -            | No   | Attribute to respectively set the radii of upper-left, upper-right, lower-right, and lower-left rounded corners                |
56e41f4b71Sopenharmony_ci| background                               | &lt;linear-gradient&gt;                  | -            | No   | Background. This attribute supports [gradient styles](js-components-common-gradient.md) only and is not compatible with **background-color** or **background-image**.|
57e41f4b71Sopenharmony_ci| background-color                         | &lt;color&gt;                            | -            | No   | Background color.                                 |
58e41f4b71Sopenharmony_ci| background-image                         | string                                   | -            | No   | Background image. This attribute is not compatible with **background-color** or **background**. Local image resources are supported. |
59e41f4b71Sopenharmony_ci| background-size                          | - string<br>- &lt;length&gt; &lt;length&gt;<br>- &lt;percentage&gt; &lt;percentage&gt; | auto         | No   | Background image size.<br>- The **string** values are as follows:<br>  - **contain**: Expands the image to the maximum size so that its height and width are fully applicable to the content area.<br>  - **cover**: Extends the background image to a large enough size so that it completely covers the background area. Some parts of the image may not be displayed in the background area.<br>  - **auto**: Retains the original aspect ratio of the image.<br>- The two **length** values are width and height of the background image. The first value indicates the width, and the second value indicates the height. If you only set one value, the other value is set to **auto** by default.<br>- The two **percentage** values are width and height of the background image in percentage of the parent element. The first value indicates the width, and the second value indicates the height. If you only set one value, the other value is set to **auto** by default. |
60e41f4b71Sopenharmony_ci| background-repeat                        | string                                   | repeat       | No   | Repeating attribute of a background image. By default, a background image is repeated both horizontally and vertically.<br>- **repeat**: The image is repeated along the x-axis and y-axis at the same time.<br>- **repeat-x**: The image is repeated along the x-axis.<br>- **repeat-y**: The image is repeated along the y-axis.<br>- **no-repeat**: The image is not repeated.|
61e41f4b71Sopenharmony_ci| background-position                      | - string string<br>- &lt;length&gt; &lt;length&gt;<br>- &lt;percentage&gt; &lt;percentage&gt; | 0px 0px | No   | - Using keywords: If only one keyword is specified, the other value is **center** by default. The two values define the horizontal position and vertical position, respectively.<br>  - **left**: leftmost in the horizontal direction.<br>  - **right**: rightmost in the horizontal direction.<br>  - **top**: top in the vertical direction.<br>  - **bottom**: bottom in the vertical direction.<br>  - **center**: center position.<br>- Using **length** values: The first value indicates the horizontal position, and the second value indicates the vertical position. For the upper left corner, the value is **0 0**. The unit is pixel. If only one value is specified, the other one is **50%**.<br>- Using **percentage** values: The first value indicates the horizontal position, and the second value indicates the vertical position. **0% 0%** indicates the upper left corner. **100% 100%** indicates the lower right corner. If only one value is specified, the other one is **50%**.<br>- Using both **percentage** and **length** values.|
62e41f4b71Sopenharmony_ci| opacity                                  | number                                   | 1            | No   | Opacity of an element. The value ranges from **0** to **1**. The value **1** means opaque, and **0** means completely transparent.       |
63e41f4b71Sopenharmony_ci
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci## Events
66e41f4b71Sopenharmony_ci
67e41f4b71Sopenharmony_ciThe following events are supported.
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci| Name        | Parameter                                      | Description                                      |
70e41f4b71Sopenharmony_ci| ---------- | ---------------------------------------- | ---------------------------------------- |
71e41f4b71Sopenharmony_ci| sizechange | { size: { height: heightLength, width: widthLength }, mode: modeStr } | Triggered when the status of the slidable panel changes. Available **mode** values are as follows:<br>- **mini**: Displays a **minibar** or **foldable** panel in its minimum size.<br>- **half**: Displays a **foldable** panel in a medium-sized (halfscreen-like) area.<br>- **full**: Displays a panel in a large (fullscreen-like) area.<br>The returned **height** value indicates the content area height. However, when the **dragbar** attribute is **true**, the **height** value is the height of the drag bar plus that of the content area.|
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci## Methods
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ciThe following methods are supported.
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ci| Name   | Parameter  | Description           |
79e41f4b71Sopenharmony_ci| ----- | ---- | ------------- |
80e41f4b71Sopenharmony_ci| show  | -    | Pops the slidable panel up.|
81e41f4b71Sopenharmony_ci| close | -    | Closes the slidable panel that has been popped up.|
82e41f4b71Sopenharmony_ci
83e41f4b71Sopenharmony_ci
84e41f4b71Sopenharmony_ci## Example
85e41f4b71Sopenharmony_ci
86e41f4b71Sopenharmony_ci```html
87e41f4b71Sopenharmony_ci<!-- xxx.hml -->
88e41f4b71Sopenharmony_ci<div class="doc-page">
89e41f4b71Sopenharmony_ci    <div class="btn-div">
90e41f4b71Sopenharmony_ci        <button type="capsule" value="Click here" onclick="showPanel"></button>
91e41f4b71Sopenharmony_ci    </div>
92e41f4b71Sopenharmony_ci    <panel id="simplepanel" type="foldable" mode="half" onsizechange="changeMode" miniheight="200px">
93e41f4b71Sopenharmony_ci        <div class="panel-div">
94e41f4b71Sopenharmony_ci            <div class="inner-txt">
95e41f4b71Sopenharmony_ci                <text class="txt">Simple panel in {{ modeFlag }} mode</text>
96e41f4b71Sopenharmony_ci            </div>
97e41f4b71Sopenharmony_ci            <div class="inner-btn">
98e41f4b71Sopenharmony_ci                <button type="capsule" value="Close" onclick="closePanel"></button>
99e41f4b71Sopenharmony_ci            </div>
100e41f4b71Sopenharmony_ci        </div>
101e41f4b71Sopenharmony_ci    </panel>
102e41f4b71Sopenharmony_ci</div>
103e41f4b71Sopenharmony_ci```
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ci```css
106e41f4b71Sopenharmony_ci/* xxx.css */
107e41f4b71Sopenharmony_ci.doc-page {
108e41f4b71Sopenharmony_ci    flex-direction: column;
109e41f4b71Sopenharmony_ci    justify-content: center;
110e41f4b71Sopenharmony_ci    align-items: center;
111e41f4b71Sopenharmony_ci}
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci.btn-div {
114e41f4b71Sopenharmony_ci    width: 100%;
115e41f4b71Sopenharmony_ci    height: 200px;
116e41f4b71Sopenharmony_ci    flex-direction: column;
117e41f4b71Sopenharmony_ci    align-items: center;
118e41f4b71Sopenharmony_ci    justify-content: center;
119e41f4b71Sopenharmony_ci}
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ci.txt {
122e41f4b71Sopenharmony_ci    color: #000000;
123e41f4b71Sopenharmony_ci    font-weight: bold;
124e41f4b71Sopenharmony_ci    font-size: 39px;
125e41f4b71Sopenharmony_ci}
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci.panel-div {
128e41f4b71Sopenharmony_ci    width: 100%;
129e41f4b71Sopenharmony_ci    flex-direction: column;
130e41f4b71Sopenharmony_ci    align-items: center;
131e41f4b71Sopenharmony_ci}
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci.inner-txt {
134e41f4b71Sopenharmony_ci    width: 100%;
135e41f4b71Sopenharmony_ci    height: 160px;
136e41f4b71Sopenharmony_ci    flex-direction: column;
137e41f4b71Sopenharmony_ci    align-items: center;
138e41f4b71Sopenharmony_ci    justify-content: center;
139e41f4b71Sopenharmony_ci}
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci.inner-btn {
142e41f4b71Sopenharmony_ci    width: 100%;
143e41f4b71Sopenharmony_ci    height: 120px;
144e41f4b71Sopenharmony_ci    justify-content: center;
145e41f4b71Sopenharmony_ci    align-items: center;
146e41f4b71Sopenharmony_ci}
147e41f4b71Sopenharmony_ci```
148e41f4b71Sopenharmony_ci
149e41f4b71Sopenharmony_ci```js
150e41f4b71Sopenharmony_ci// xxx.js
151e41f4b71Sopenharmony_ciexport default {
152e41f4b71Sopenharmony_ci  data: {
153e41f4b71Sopenharmony_ci    modeFlag: "half"
154e41f4b71Sopenharmony_ci  },
155e41f4b71Sopenharmony_ci  showPanel() {
156e41f4b71Sopenharmony_ci    this.$element('simplepanel').show()
157e41f4b71Sopenharmony_ci  },
158e41f4b71Sopenharmony_ci  closePanel() {
159e41f4b71Sopenharmony_ci    this.$element('simplepanel').close()
160e41f4b71Sopenharmony_ci  },
161e41f4b71Sopenharmony_ci  changeMode(e) {
162e41f4b71Sopenharmony_ci    this.modeFlag = e.mode
163e41f4b71Sopenharmony_ci  }
164e41f4b71Sopenharmony_ci}
165e41f4b71Sopenharmony_ci```
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci![panel6](figures/panel6.gif)
168