1e41f4b71Sopenharmony_ci# @ohos.atomicservice.AtomicServiceTabs (Tabs Container) 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ci**AtomicServiceTabs** is an advanced component designed to streamline the use of the **Tabs** component by limiting customization options. It restricts the display to a maximum of five tabs, with fixed styles, positions, and sizes for the tabs. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> This component is supported since API version 12. Updates will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci## Modules to Import 10e41f4b71Sopenharmony_ci 11e41f4b71Sopenharmony_ci``` 12e41f4b71Sopenharmony_ciimport { AtomicServiceTabs, TabBarOptions, TabBarPosition, OnContentWillChangeCallback } from '@kit.ArkUI'; 13e41f4b71Sopenharmony_ci``` 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci## Child Components 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ciNot supported 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ci## Attributes 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ciThe [universal attributes](ts-universal-attributes-size.md) are not supported. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci## AtomicServiceTabs 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ciAtomicServiceTabs ({\ 26e41f4b71Sopenharmony_ci tabContents?: [ TabContentBuilder?, 27e41f4b71Sopenharmony_ci TabContentBuilder?, 28e41f4b71Sopenharmony_ci TabContentBuilder?, 29e41f4b71Sopenharmony_ci TabContentBuilder?, 30e41f4b71Sopenharmony_ci TabContentBuilder? 31e41f4b71Sopenharmony_ci ],\ 32e41f4b71Sopenharmony_ci tabBarOptionsArray: [ TabBarOptions, 33e41f4b71Sopenharmony_ci TabBarOptions, 34e41f4b71Sopenharmony_ci TabBarOptions?, 35e41f4b71Sopenharmony_ci TabBarOptions?, 36e41f4b71Sopenharmony_ci TabBarOptions? 37e41f4b71Sopenharmony_ci ],\ 38e41f4b71Sopenharmony_ci tabBarPosition?: TabBarPosition,\ 39e41f4b71Sopenharmony_ci barBackgroundColor?: ResourceColor,\ 40e41f4b71Sopenharmony_ci index?: number,\ 41e41f4b71Sopenharmony_ci barOverlap?: boolean,\ 42e41f4b71Sopenharmony_ci controller?: TabsController,\ 43e41f4b71Sopenharmony_ci onChange?: Callback\<number>,\ 44e41f4b71Sopenharmony_ci onTabBarClick?: Callback\<number>,\ 45e41f4b71Sopenharmony_ci onContentWillChange?: OnContentWillChangeCallback,\ 46e41f4b71Sopenharmony_ci}) 47e41f4b71Sopenharmony_ci 48e41f4b71Sopenharmony_ci**Decorator**: \@Component 49e41f4b71Sopenharmony_ci 50e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 51e41f4b71Sopenharmony_ci 52e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci**Parameters** 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Decorator | Description | 57e41f4b71Sopenharmony_ci| --------------- | ------ | ---- | ----|----------| 58e41f4b71Sopenharmony_ci| tabContents | [[TabContentBuilder?](#tabcontentbuilder),[TabContentBuilder?](#tabcontentbuilder), [TabContentBuilder?](#tabcontentbuilder),[TabContentBuilder?](#tabcontentbuilder), [TabContentBuilder?](#tabcontentbuilder)] | No | @BuilderParam| Array of content view containers.| 59e41f4b71Sopenharmony_ci| tabBarOptionsArray | [[TabBarOptions?](#tabbaroptions),[TabBarOptions?](#tabbaroptions), [TabBarOptions?](#tabbaroptions),[TabBarOptions?](#tabbaroptions), [TabBarOptions?](#tabbaroptions)] | Yes | @Prop | Array of tab bar container configurations. | 60e41f4b71Sopenharmony_ci| tabBarPosition | [TabBarPosition](#tabbarposition) | No |@Prop | Position of the tab bar.| 61e41f4b71Sopenharmony_ci| barBackgroundColor | [ResourceColor](ts-types.md#resourcecolor) | No | @Prop | Background color of the tab bar.| 62e41f4b71Sopenharmony_ci| index | number | No | @Prop | Index of the currently displayed tab.| 63e41f4b71Sopenharmony_ci| barOverlap | boolean| No | @Prop | Whether the tab bar is superimposed on the **TabContent** component after having its background blurred.| 64e41f4b71Sopenharmony_ci| controller|[TabsController](ts-container-tabs#tabscontroller) | No | @Prop |Tab controller, which is used to control switching of tabs.| 65e41f4b71Sopenharmony_ci| onChange | Callback\<number\> | No | - | Callback invoked when a tab is switched. | 66e41f4b71Sopenharmony_ci| onTabBarClick | Callback\<number\> | No | - |Callback invoked when a tab is clicked.| 67e41f4b71Sopenharmony_ci| onContentWillChange | [OnContentWillChangeCallback](#oncontentwillchangecallback) | No | - | Callback invoked when a new page is about to be displayed.| 68e41f4b71Sopenharmony_ci 69e41f4b71Sopenharmony_ci## TabContentBuilder 70e41f4b71Sopenharmony_ci 71e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 72e41f4b71Sopenharmony_ci 73e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 74e41f4b71Sopenharmony_ci 75e41f4b71Sopenharmony_ci| Type | Description | 76e41f4b71Sopenharmony_ci| ---- | ---------- | 77e41f4b71Sopenharmony_ci| () => void | Content view container. | 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci## TabBarOptions 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 84e41f4b71Sopenharmony_ci 85e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 86e41f4b71Sopenharmony_ci| --------------- | ------ |------ |------ | 87e41f4b71Sopenharmony_ci| icon | [ResourceStr](ts-types.md#resourcestr) \| [TabBarSymbol](#tabbarsymbol12) | Yes | Icon of the tab. | 88e41f4b71Sopenharmony_ci| text | [ResourceStr](ts-types.md#resourcestr) | Yes | Text of the tab. | 89e41f4b71Sopenharmony_ci| unselectedColor | [ResourceColor](ts-types.md#resourcecolor) | Yes | Color of the tab when it is not selected. | 90e41f4b71Sopenharmony_ci| selectedColor | [ResourceColor](ts-types.md#resourcecolor) | Yes | Color of the tab when it is selected. | 91e41f4b71Sopenharmony_ci 92e41f4b71Sopenharmony_ci## TabBarPosition 93e41f4b71Sopenharmony_ci 94e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 95e41f4b71Sopenharmony_ci 96e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ci| Name | Value | Description | 99e41f4b71Sopenharmony_ci| --------------- | ------ |-----| 100e41f4b71Sopenharmony_ci| LEFT | 0 | The tab bar is on the left side of the screen. | 101e41f4b71Sopenharmony_ci| BOTTOM | 1 | The tab bar is at the bottom of the screen. | 102e41f4b71Sopenharmony_ci 103e41f4b71Sopenharmony_ci## OnContentWillChangeCallback 104e41f4b71Sopenharmony_ci 105e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 106e41f4b71Sopenharmony_ci 107e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 110e41f4b71Sopenharmony_ci| --------------- | ------ |------ |------ | 111e41f4b71Sopenharmony_ci| currentIndex | number | Yes | Index of the current tab. | 112e41f4b71Sopenharmony_ci| comingIndex | number | Yes | Index of the tab to be switched to. | 113e41f4b71Sopenharmony_ci 114e41f4b71Sopenharmony_ci## Example 115e41f4b71Sopenharmony_ci 116e41f4b71Sopenharmony_ci```ts 117e41f4b71Sopenharmony_ci// Index.ets 118e41f4b71Sopenharmony_ciimport { AtomicServiceTabs, TabBarOptions, TabBarPosition, OnContentWillChangeCallback } from '@kit.ArkUI'; 119e41f4b71Sopenharmony_ci 120e41f4b71Sopenharmony_ci@Entry 121e41f4b71Sopenharmony_ci@Component 122e41f4b71Sopenharmony_cistruct Index { 123e41f4b71Sopenharmony_ci @State message: string = 'Home'; 124e41f4b71Sopenharmony_ci @State onClickNumber: number = 0; 125e41f4b71Sopenharmony_ci @State currentIndex: number = 0; 126e41f4b71Sopenharmony_ci @State comingIndex: number = 0; 127e41f4b71Sopenharmony_ci onContentWillChangeCallBack: OnContentWillChangeCallback = (currentIndex: number, comingIndex: number): boolean => { 128e41f4b71Sopenharmony_ci this.currentIndex = currentIndex; 129e41f4b71Sopenharmony_ci this.comingIndex = comingIndex; 130e41f4b71Sopenharmony_ci console.log('OnContentWillChangeCallback') 131e41f4b71Sopenharmony_ci return true; 132e41f4b71Sopenharmony_ci } 133e41f4b71Sopenharmony_ci onTabClick: Callback<number> = (index:number)=>{ 134e41f4b71Sopenharmony_ci this.onClickNumber ++; 135e41f4b71Sopenharmony_ci console.log('onTabClick'); 136e41f4b71Sopenharmony_ci } 137e41f4b71Sopenharmony_ci @Builder 138e41f4b71Sopenharmony_ci tabContent1() { 139e41f4b71Sopenharmony_ci Column().width('100%').height('100%').alignItems(HorizontalAlign.Center).backgroundColor('#00CB87') 140e41f4b71Sopenharmony_ci } 141e41f4b71Sopenharmony_ci 142e41f4b71Sopenharmony_ci @Builder 143e41f4b71Sopenharmony_ci tabContent2() { 144e41f4b71Sopenharmony_ci Column().width('100%').height('100%').backgroundColor('#007DFF') 145e41f4b71Sopenharmony_ci } 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_ci @Builder 148e41f4b71Sopenharmony_ci tabContent3() { 149e41f4b71Sopenharmony_ci Column().width('100%').height('100%').backgroundColor('#FFBF00') 150e41f4b71Sopenharmony_ci } 151e41f4b71Sopenharmony_ci 152e41f4b71Sopenharmony_ci build() { 153e41f4b71Sopenharmony_ci Stack() { 154e41f4b71Sopenharmony_ci AtomicServiceTabs({ 155e41f4b71Sopenharmony_ci tabContents: [ 156e41f4b71Sopenharmony_ci () => { 157e41f4b71Sopenharmony_ci this.tabContent1() 158e41f4b71Sopenharmony_ci }, 159e41f4b71Sopenharmony_ci () => { 160e41f4b71Sopenharmony_ci this.tabContent2() 161e41f4b71Sopenharmony_ci }, 162e41f4b71Sopenharmony_ci () => { 163e41f4b71Sopenharmony_ci this.tabContent3() 164e41f4b71Sopenharmony_ci } 165e41f4b71Sopenharmony_ci ], 166e41f4b71Sopenharmony_ci tabBarOptionsArray: [ 167e41f4b71Sopenharmony_ci new TabBarOptions($r('sys.media.ohos_ic_public_phone'), 'Green', Color.Black, Color.Blue), 168e41f4b71Sopenharmony_ci new TabBarOptions($r('sys.media.ohos_ic_public_location'), 'Blue', Color.Black, Color.Blue), 169e41f4b71Sopenharmony_ci new TabBarOptions($r('sys.media.ohos_ic_public_more'), 'Yellow', Color.Black, Color.Blue) 170e41f4b71Sopenharmony_ci ], 171e41f4b71Sopenharmony_ci tabBarPosition: TabBarPosition.BOTTOM, 172e41f4b71Sopenharmony_ci barBackgroundColor: $r('sys.color.ohos_id_color_bottom_tab_bg'), 173e41f4b71Sopenharmony_ci onTabBarClick:this.onTabClick, 174e41f4b71Sopenharmony_ci onContentWillChange: this.onContentWillChangeCallBack, 175e41f4b71Sopenharmony_ci }) 176e41f4b71Sopenharmony_ci Column() { 177e41f4b71Sopenharmony_ci Text("onChange callback times:" + this.onClickNumber) 178e41f4b71Sopenharmony_ci Text("comingIndex = " + this.comingIndex + ", currentIndex = " + this.currentIndex) 179e41f4b71Sopenharmony_ci }.margin({top:500}) 180e41f4b71Sopenharmony_ci }.height('100%') 181e41f4b71Sopenharmony_ci } 182e41f4b71Sopenharmony_ci} 183e41f4b71Sopenharmony_ci``` 184e41f4b71Sopenharmony_ci 185