# SideBarContainer
The **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.
> **NOTE**
>
> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version.
## Child Components
Supported
> **NOTE**
>
> - 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.
> - This component must contain two child components.
> - 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.
## APIs
SideBarContainer( type?: SideBarContainerType )
**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|
| -------- | -------- | -------- | -------- |
| type | [SideBarContainerType](#sidebarcontainertype) | No| Display type of the sidebar.
Default value: **SideBarContainerType.Embed**|
## SideBarContainerType
**Atomic service API**: This API can be used in atomic services since API version 11.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name| Description|
| -------- | -------- |
| Embed | The sidebar is embedded in the component and displayed side by side with the content area.
When the component size is less than the sum of **minContentWidth** and **minSideBarWidth** and **showSideBar** is not set, the sidebar is automatically hidden.
If **minSideBarWidth** or **minContentWidth** is not set, the default value will be used for calculation.
The user can bring out the sidebar in Overlay mode by clicking the control button.|
| Overlay | The sidebar is displayed overlaid on the content area.|
| AUTO10+ | The sidebar is displayed in Embed mode when the component size is greater than or equal to the sum of **minSideBarWidth** and **minContentWidth** and in Overlay mode otherwise.
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.|
## Attributes
In addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
### showSideBar
showSideBar(value: boolean)
Specifies whether to display the sidebar.
Since API version 10, this attribute supports two-way binding through [$$](../../../quick-start/arkts-two-way-sync.md).
**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 sidebar.
**true**: The sidebar is displayed.
**false**: The sidebar is not displayed.
Default value: **true**|
### controlButton
controlButton(value: ButtonStyle)
Sets the attributes of the sidebar control button.
**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 | [ButtonStyle](#buttonstyle) | Yes | Attributes of the sidebar control button.|
### showControlButton
showControlButton(value: boolean)
Specifies whether to display the sidebar control button.
**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 sidebar control button.
**true**: The sidebar control button is displayed.
**false**: The sidebar control button is not displayed.
Default value: **true**|
### sideBarWidth
sideBarWidth(value: number | Length)
Sets 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.
**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 \| [Length](ts-types.md#length)9+ | Yes | Width of the sidebar.
Default value: **240vp**
Unit: vp
**NOTE**
In API version 9 and earlier versions, the default value is **200vp**. In API version 10, the default value is **240vp**.|
### minSideBarWidth
minSideBarWidth(value: number | Length)
Sets 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.
**minSideBarWidth**, whether it is specified or kept at the default value, takes precedence over **minWidth** of the sidebar child components.
**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 \| [Length](ts-types.md#length)9+ | Yes | Minimum width of the sidebar.
Default value: **240vp**
Unit: vp
**NOTE**
In API version 9 and earlier versions, the default value is **200vp**. In API version 10, the default value is **240vp**.|
### maxSideBarWidth
maxSideBarWidth(value: number | Length)
Sets 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.
**maxSideBarWidth**, whether it is specified or kept at the default value, takes precedence over **maxWidth** of the sidebar child components.
**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 \| [Length](ts-types.md#length)9+ | Yes | Maximum width of the sidebar.
Default value: **280vp**
Unit: vp|
### autoHide9+
autoHide(value: boolean)
Specifies 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.
Whether 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).
**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 automatically hide the sidebar when it is dragged to be smaller than the minimum width.
**true**: The sidebar is automatically hidden.
**false**: The sidebar is not automatically hidden.
Default value: **true**|
### sideBarPosition9+
sideBarPosition(value: SideBarPosition)
Sets the position of the sidebar.
**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 | [SideBarPosition](#sidebarposition9) | Yes | Position of the sidebar.
Default value: **SideBarPosition.Start**|
### divider10+
divider(value: DividerStyle | null)
Sets the divider style.
**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 | [DividerStyle](#dividerstyle10) \| null | Yes | Divider style.
- **DividerStyle** (default): The divider is displayed.
- **null** or **undefined**: No action is taken, and the divider style remains consistent with the default.
**NOTE**
In API version 11 and earlier versions, **null** results in the divider not being displayed.|
### minContentWidth10+
minContentWidth(value: Dimension)
Sets the minimum content area width of the sidebar container.
If 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.
In Embed mode, when the component size is increased, only the content area is enlarged;
when 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
until its width reaches the value defined by **minSideBarWidth**; if the component size is further decreased, then:
- If **autoHide** is set to **false**, while respecting the **minSideBarWidth** and **minContentWidth** settings, the content area has its content clipped.
- 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.
**minContentWidth**, whether it is specified or kept at the default value, takes precedence over **minSideBarWidth** and **sideBarWidth** of the sidebar.
**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](ts-types.md#dimension10) | Yes | Minimum content area width of the sidebar container.
Default value: **360vp**
Unit: vp|
## ButtonStyle
**Atomic service API**: This API can be used in atomic services since API version 11.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- |
| left | number | No| Spacing between the sidebar control button and the left of the container.
Default value: **16vp**
Unit: vp|
| top | number | No| Spacing between the sidebar control button and the top of the container.
Default value: **48vp**
Unit: vp|
| width | number | No| Width of the sidebar control button.
Default value:
API version 9 and earlier versions: **32vp**
API version 10 and later versions: **24vp**
Unit: vp|
| height | number | No| Height of the sidebar control button.
Default value:
API version 9 and earlier versions: **32vp**
API version 10 and later versions: **24vp**
Unit: vp|
| icons | {
shown: string \| PixelMap \| [Resource](ts-types.md) ,
hidden: string \| PixelMap \| [Resource](ts-types.md) ,
switching?: string \| PixelMap \| [Resource](ts-types.md)
} | No| Icons of the sidebar control button.