1e41f4b71Sopenharmony_ci# SideBarContainer
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **SideBarContainer** component contains a sidebar and content area as its child components. The sidebar is the first child component and can be shown or hidden as needed. The content area is the second child component.
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci>  **NOTE**
6e41f4b71Sopenharmony_ci>
7e41f4b71Sopenharmony_ci>  This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci
10e41f4b71Sopenharmony_ci## Child Components
11e41f4b71Sopenharmony_ci
12e41f4b71Sopenharmony_ciSupported
13e41f4b71Sopenharmony_ci
14e41f4b71Sopenharmony_ci>  **NOTE**
15e41f4b71Sopenharmony_ci>
16e41f4b71Sopenharmony_ci>  - Built-in components and custom components are allowed, without 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.
17e41f4b71Sopenharmony_ci>  - This component must contain two child components.
18e41f4b71Sopenharmony_ci>  - If there are three or more child components, only the first and second child components are displayed. If there is only one child component, the sidebar is displayed, and the content area is blank.
19e41f4b71Sopenharmony_ci
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci## APIs
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ciSideBarContainer( type?: SideBarContainerType )
24e41f4b71Sopenharmony_ci
25e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
26e41f4b71Sopenharmony_ci
27e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci**Parameters**
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
32e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
33e41f4b71Sopenharmony_ci| type | [SideBarContainerType](#sidebarcontainertype) | No| Display type of the sidebar.<br>Default value: **SideBarContainerType.Embed**|
34e41f4b71Sopenharmony_ci
35e41f4b71Sopenharmony_ci## SideBarContainerType
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci| Name| Description|
42e41f4b71Sopenharmony_ci| -------- | -------- |
43e41f4b71Sopenharmony_ci| Embed | The sidebar is embedded in the component and displayed side by side with the content area.<br>When the component size is less than the sum of **minContentWidth** and **minSideBarWidth** and **showSideBar** is not set, the sidebar is automatically hidden.<br>If **minSideBarWidth** or **minContentWidth** is not set, the default value will be used for calculation.<br> The user can bring out the sidebar in Overlay mode by clicking the control button.|
44e41f4b71Sopenharmony_ci| Overlay | The sidebar is displayed overlaid on the content area.|
45e41f4b71Sopenharmony_ci| AUTO<sup>10+</sup> | The sidebar is displayed in Embed mode when the component size is greater than or equal to the sum of **minSideBarWidth** and **minContentWidth**<br>and in Overlay mode otherwise.<br>If **minSideBarWidth** or **minContentWidth** is not set, the default value will be used for calculation. If the calculation result is less than 600 vp, 600 vp will be used as the breakpoint value for mode switching.|
46e41f4b71Sopenharmony_ci
47e41f4b71Sopenharmony_ci## Attributes
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ciIn addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
50e41f4b71Sopenharmony_ci
51e41f4b71Sopenharmony_ci### showSideBar
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_cishowSideBar(value: boolean)
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ciSpecifies whether to display the sidebar.
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ciSince API version 10, this attribute supports two-way binding through [$$](../../../quick-start/arkts-two-way-sync.md).
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci**Parameters**
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci| Name| Type   | Mandatory| Description                                                        |
66e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------------------------------ |
67e41f4b71Sopenharmony_ci| value  | boolean | Yes  | Whether to display the sidebar.<br>**true**: The sidebar is displayed.<br>**false**: The sidebar is not displayed.<br>Default value: **true**|
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci### controlButton
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_cicontrolButton(value: ButtonStyle)
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ciSets the attributes of the sidebar control button.
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci**Parameters**
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci| Name| Type                               | Mandatory| Description                  |
82e41f4b71Sopenharmony_ci| ------ | ----------------------------------- | ---- | ---------------------- |
83e41f4b71Sopenharmony_ci| value  | [ButtonStyle](#buttonstyle) | Yes  | Attributes of the sidebar control button.|
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci### showControlButton
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_cishowControlButton(value: boolean)
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ciSpecifies whether to display the sidebar control button.
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci**Parameters**
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci| Name| Type   | Mandatory| Description                                                        |
98e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------------------------------ |
99e41f4b71Sopenharmony_ci| value  | boolean | Yes  | Whether to display the sidebar control button.<br>**true**: The sidebar control button is displayed.<br>**false**: The sidebar control button is not displayed.<br>Default value: **true**|
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci### sideBarWidth
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_cisideBarWidth(value: number | Length)
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ciSets the width of the sidebar. A value less than 0 evaluates to the default value. The value must comply with the width constraints. If it is not within the valid range, the valid value closest to the set one is used.
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci**Parameters**
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description                                                        |
114e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
115e41f4b71Sopenharmony_ci| value  | number \| [Length](ts-types.md#length)<sup>9+</sup> | Yes  | Width of the sidebar.<br>Default value: **240vp**<br>Unit: vp<br>**NOTE**<br>In API version 9 and earlier versions, the default value is **200vp**. In API version 10, the default value is **240vp**.|
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci### minSideBarWidth
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_ciminSideBarWidth(value: number | Length)
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ciSets the minimum width of the sidebar. A value less than 0 evaluates to the default value. The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ci**minSideBarWidth**, whether it is specified or kept at the default value, takes precedence over **minWidth** of the sidebar child components.
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci**Parameters**
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description                                                        |
132e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
133e41f4b71Sopenharmony_ci| value  | number \| [Length](ts-types.md#length)<sup>9+</sup> | Yes  | Minimum width of the sidebar.<br>Default value: **240vp**<br>Unit: vp<br>**NOTE**<br>In API version 9 and earlier versions, the default value is **200vp**. In API version 10, the default value is **240vp**.|
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci### maxSideBarWidth
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_cimaxSideBarWidth(value: number | Length)
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ciSets the maximum width of the sidebar. A value less than 0 evaluates to the default value. The value cannot exceed the width of the sidebar container itself. Otherwise, the width of the sidebar container itself is used.
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci**maxSideBarWidth**, whether it is specified or kept at the default value, takes precedence over **maxWidth** of the sidebar child components.
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci**Parameters**
148e41f4b71Sopenharmony_ci
149e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description                                               |
150e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | --------------------------------------------------- |
151e41f4b71Sopenharmony_ci| value  | number \| [Length](ts-types.md#length)<sup>9+</sup> | Yes  | Maximum width of the sidebar.<br>Default value: **280vp**<br>Unit: vp|
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci### autoHide<sup>9+</sup>
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ciautoHide(value: boolean)
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ciSpecifies whether to automatically hide the sidebar when it is dragged to be smaller than the minimum width. The value is subject to the **minSideBarWidth** attribute method. If it is not set in **minSideBarWidth**, the default value is used.
158e41f4b71Sopenharmony_ci
159e41f4b71Sopenharmony_ciWhether the sidebar should be hidden is determined when it is being dragged. When it is dragged to be smaller than the minimum width, the damping effect is required to trigger hiding (a distance out of range).
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ci**Parameters**
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci| Name| Type   | Mandatory| Description                                                        |
168e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------------------------------ |
169e41f4b71Sopenharmony_ci| value  | boolean | Yes  | Whether to automatically hide the sidebar when it is dragged to be smaller than the minimum width.<br>**true**: The sidebar is automatically hidden.<br>**false**: The sidebar is not automatically hidden.<br>Default value: **true**|
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ci### sideBarPosition<sup>9+</sup>
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_cisideBarPosition(value: SideBarPosition)
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ciSets the position of the sidebar.
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci**Parameters**
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci| Name| Type                                        | Mandatory| Description                                              |
184e41f4b71Sopenharmony_ci| ------ | -------------------------------------------- | ---- | -------------------------------------------------- |
185e41f4b71Sopenharmony_ci| value  | [SideBarPosition](#sidebarposition9) | Yes  | Position of the sidebar.<br>Default value: **SideBarPosition.Start**|
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci### divider<sup>10+</sup>
188e41f4b71Sopenharmony_ci
189e41f4b71Sopenharmony_cidivider(value: DividerStyle | null)
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ciSets the divider style.
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
196e41f4b71Sopenharmony_ci
197e41f4b71Sopenharmony_ci**Parameters**
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci| Name| Type                                                     | Mandatory| Description                                                        |
200e41f4b71Sopenharmony_ci| ------ | --------------------------------------------------------- | ---- | ------------------------------------------------------------ |
201e41f4b71Sopenharmony_ci| value  | [DividerStyle](#dividerstyle10) \| null | Yes  | Divider style.<br>- **DividerStyle** (default): The divider is displayed.<br>- **null** or **undefined**: No action is taken, and the divider style remains consistent with the default.<br>**NOTE**<br>In API version 11 and earlier versions, **null** results in the divider not being displayed.|
202e41f4b71Sopenharmony_ci
203e41f4b71Sopenharmony_ci### minContentWidth<sup>10+</sup>
204e41f4b71Sopenharmony_ci
205e41f4b71Sopenharmony_ciminContentWidth(value: Dimension)
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ciSets the minimum content area width of the sidebar container.
208e41f4b71Sopenharmony_ci
209e41f4b71Sopenharmony_ciIf this attribute is set to a value less than 0, the default value **360vp** will be used. If this attribute is not set, the width of the content area can shrink to 0.
210e41f4b71Sopenharmony_ci
211e41f4b71Sopenharmony_ciIn Embed mode, when the component size is increased, only the content area is enlarged;
212e41f4b71Sopenharmony_ci
213e41f4b71Sopenharmony_ciwhen the component size is decreased, the content area is shrunk until its width reaches the value defined by **minContentWidth**; if the component size is further decreased, while respecting the **minContentWidth** settings, the sidebar is shrunk
214e41f4b71Sopenharmony_ci
215e41f4b71Sopenharmony_ciuntil its width reaches the value defined by **minSideBarWidth**; if the component size is further decreased, then:
216e41f4b71Sopenharmony_ci
217e41f4b71Sopenharmony_ci- If **autoHide** is set to **false**, while respecting the **minSideBarWidth** and **minContentWidth** settings, the content area has its content clipped.
218e41f4b71Sopenharmony_ci- If **autoHide** is set to **true**, the sidebar is hidden first, and then the content area is shrunk. After its width reaches the value defined by **minContentWidth**, the content area has its content clipped.
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci**minContentWidth**, whether it is specified or kept at the default value, takes precedence over **minSideBarWidth** and **sideBarWidth** of the sidebar.
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ci**Parameters**
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci| Name| Type                                | Mandatory| Description                                                        |
229e41f4b71Sopenharmony_ci| ------ | ------------------------------------ | ---- | ------------------------------------------------------------ |
230e41f4b71Sopenharmony_ci| value  | [Dimension](ts-types.md#dimension10) | Yes  | Minimum content area width of the sidebar container.<br>Default value: **360vp**<br>Unit: vp|
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci## ButtonStyle
233e41f4b71Sopenharmony_ci
234e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
237e41f4b71Sopenharmony_ci
238e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description|
239e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- |
240e41f4b71Sopenharmony_ci| left | number | No| Spacing between the sidebar control button and the left of the container.<br>Default value: **16vp**<br>Unit: vp|
241e41f4b71Sopenharmony_ci| top | number | No| Spacing between the sidebar control button and the top of the container.<br>Default value: **48vp**<br>Unit: vp|
242e41f4b71Sopenharmony_ci| width | number | No| Width of the sidebar control button.<br>Default value:<br>API version 9 and earlier versions: **32vp**<br>API version 10 and later versions: **24vp**<br>Unit: vp|
243e41f4b71Sopenharmony_ci| height | number | No| Height of the sidebar control button.<br>Default value:<br>API version 9 and earlier versions: **32vp**<br>API version 10 and later versions: **24vp**<br>Unit: vp|
244e41f4b71Sopenharmony_ci| icons | {<br>shown: string \| PixelMap \| [Resource](ts-types.md) ,<br>hidden: string \| PixelMap \| [Resource](ts-types.md) ,<br>switching?: string \| PixelMap \| [Resource](ts-types.md) <br>} | No| Icons of the sidebar control button.<br> </p> - **shown**: icon of the control button when the sidebar is shown.<br>**NOTE**<br>When an error occurs during resource obtaining, the default icon is used.<br>- **hidden**: icon of the control button when the sidebar is hidden.<br>- **switching**: icon of the control button when the sidebar is switching between the shown and hidden states.|
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ci## SideBarPosition<sup>9+</sup>
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ciEnumerates the positions of the sidebar.
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci| Name| Description|
255e41f4b71Sopenharmony_ci| -------- | -------- |
256e41f4b71Sopenharmony_ci| Start | The sidebar is on the left side of the container.|
257e41f4b71Sopenharmony_ci| End | The sidebar is on the right side of the container.|
258e41f4b71Sopenharmony_ci
259e41f4b71Sopenharmony_ci## DividerStyle<sup>10+</sup>
260e41f4b71Sopenharmony_ci
261e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
262e41f4b71Sopenharmony_ci
263e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_ci| Name       | Type     | Mandatory| Description                                    |
266e41f4b71Sopenharmony_ci| ----------- | ------------- | ---- | ---------------------------------------- |
267e41f4b71Sopenharmony_ci| strokeWidth | [Length](ts-types.md#length)        | Yes  | Stroke width of the divider.<br>Default value: **1vp**|
268e41f4b71Sopenharmony_ci| color       | [ResourceColor](ts-types.md#resourcecolor) | No  | Color of the divider.<br>Default value: **#000000, 3%**  |
269e41f4b71Sopenharmony_ci| startMargin | [Length](ts-types.md#length)        | No  | Distance between the divider and the top of the sidebar.<br>Default value: **0**|
270e41f4b71Sopenharmony_ci| endMargin   | [Length](ts-types.md#length)        | No  | Distance between the divider and the bottom of the sidebar.<br>Default value: **0**|
271e41f4b71Sopenharmony_ci>  **NOTE**
272e41f4b71Sopenharmony_ci>
273e41f4b71Sopenharmony_ci>  The settings of the [universal size attributes](ts-universal-attributes-size.md) **width** and **height** do not take effect for the sidebar child component.
274e41f4b71Sopenharmony_ci>  The settings do not take effect for the sidebar content area either. By default, the sidebar content area takes up the remaining space of the sidebar container.
275e41f4b71Sopenharmony_ci>
276e41f4b71Sopenharmony_ci>  If the **showSideBar** attribute is not set, the sidebar's visibility is subject to its size.
277e41f4b71Sopenharmony_ci>
278e41f4b71Sopenharmony_ci>  - If the size is less than the sum of **minSideBarWidth** and **minContentWidth**, the sidebar is not displayed by default.
279e41f4b71Sopenharmony_ci>  - If the size is greater than or equal to the sum of **minSideBarWidth** and **minContentWidth**, the sidebar is displayed by default.
280e41f4b71Sopenharmony_ci
281e41f4b71Sopenharmony_ci## Events
282e41f4b71Sopenharmony_ci
283e41f4b71Sopenharmony_ciIn addition to the [universal events](ts-universal-events-click.md), the following events are supported.
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ci### onChange
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_cionChange(callback: (value: boolean) =&gt; void)
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_ciTriggered when the status of the sidebar switches between shown and hidden.
290e41f4b71Sopenharmony_ci
291e41f4b71Sopenharmony_ciThis event is triggered when any of the following conditions is met:
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_ci1. The value of **showSideBar** changes.
294e41f4b71Sopenharmony_ci
295e41f4b71Sopenharmony_ci2. The **showSideBar** attribute adapts to behavior changes.
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci3. The **autoHide** API is triggered when the divider is dragged.
298e41f4b71Sopenharmony_ci
299e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci**Parameters**
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ci| Name| Type   | Mandatory| Description                         |
306e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ----------------------------- |
307e41f4b71Sopenharmony_ci| value  | boolean | Yes  | The value **true** means that the sidebar is displayed, and **false** means the opposite.|
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_ci
310e41f4b71Sopenharmony_ci## Example
311e41f4b71Sopenharmony_ci
312e41f4b71Sopenharmony_ci```ts
313e41f4b71Sopenharmony_ci// xxx.ets
314e41f4b71Sopenharmony_ci@Entry
315e41f4b71Sopenharmony_ci@Component
316e41f4b71Sopenharmony_cistruct SideBarContainerExample {
317e41f4b71Sopenharmony_ci  normalIcon: Resource = $r("app.media.icon")
318e41f4b71Sopenharmony_ci  selectedIcon: Resource = $r("app.media.icon")
319e41f4b71Sopenharmony_ci  @State arr: number[] = [1, 2, 3]
320e41f4b71Sopenharmony_ci  @State current: number = 1
321e41f4b71Sopenharmony_ci
322e41f4b71Sopenharmony_ci  build() {
323e41f4b71Sopenharmony_ci    SideBarContainer(SideBarContainerType.Embed) {
324e41f4b71Sopenharmony_ci      Column() {
325e41f4b71Sopenharmony_ci        ForEach(this.arr, (item: number) => {
326e41f4b71Sopenharmony_ci          Column({ space: 5 }) {
327e41f4b71Sopenharmony_ci            Image(this.current === item ? this.selectedIcon : this.normalIcon).width(64).height(64)
328e41f4b71Sopenharmony_ci            Text("Index0" + item)
329e41f4b71Sopenharmony_ci              .fontSize(25)
330e41f4b71Sopenharmony_ci              .fontColor(this.current === item ? '#0A59F7' : '#999')
331e41f4b71Sopenharmony_ci              .fontFamily('source-sans-pro,cursive,sans-serif')
332e41f4b71Sopenharmony_ci          }
333e41f4b71Sopenharmony_ci          .onClick(() => {
334e41f4b71Sopenharmony_ci            this.current = item
335e41f4b71Sopenharmony_ci          })
336e41f4b71Sopenharmony_ci        }, (item: string) => item)
337e41f4b71Sopenharmony_ci      }.width('100%')
338e41f4b71Sopenharmony_ci      .justifyContent(FlexAlign.SpaceEvenly)
339e41f4b71Sopenharmony_ci      .backgroundColor('#19000000')
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci      Column() {
342e41f4b71Sopenharmony_ci        Text('SideBarContainer content text1').fontSize(25)
343e41f4b71Sopenharmony_ci        Text('SideBarContainer content text2').fontSize(25)
344e41f4b71Sopenharmony_ci      }
345e41f4b71Sopenharmony_ci      .margin({ top: 50, left: 20, right: 30 })
346e41f4b71Sopenharmony_ci    }
347e41f4b71Sopenharmony_ci    .controlButton({
348e41f4b71Sopenharmony_ci      icons: {
349e41f4b71Sopenharmony_ci        hidden: $r('app.media.drawer'),
350e41f4b71Sopenharmony_ci        shown: $r('app.media.drawer'),
351e41f4b71Sopenharmony_ci        switching: $r('app.media.drawer')
352e41f4b71Sopenharmony_ci      }
353e41f4b71Sopenharmony_ci    })
354e41f4b71Sopenharmony_ci    .sideBarWidth(150)
355e41f4b71Sopenharmony_ci    .minSideBarWidth(50)
356e41f4b71Sopenharmony_ci    .maxSideBarWidth(300)
357e41f4b71Sopenharmony_ci    .minContentWidth(0)
358e41f4b71Sopenharmony_ci    .onChange((value: boolean) => {
359e41f4b71Sopenharmony_ci      console.info('status:' + value)
360e41f4b71Sopenharmony_ci    })
361e41f4b71Sopenharmony_ci    .divider({ strokeWidth: '1vp', color: Color.Gray, startMargin: '4vp', endMargin: '4vp' })
362e41f4b71Sopenharmony_ci  }
363e41f4b71Sopenharmony_ci}
364e41f4b71Sopenharmony_ci```
365e41f4b71Sopenharmony_ci
366e41f4b71Sopenharmony_ci![](figures/sidebarcontainer.png)
367