1e41f4b71Sopenharmony_ci 2e41f4b71Sopenharmony_ci# @ohos.atomicservice.AtomicServiceNavigation (Navigation Root View Container) 3e41f4b71Sopenharmony_ci 4e41f4b71Sopenharmony_ci**AtomicServiceNavigation** is a component that serves as the root container of a page. By default, it includes a title bar, content area, and toolbar. The content area switches between the home page content (child components of [NavDestination](ts-basic-components-navdestination.md)) and non-home page content through routing. 5e41f4b71Sopenharmony_ci 6e41f4b71Sopenharmony_ci> **NOTE** 7e41f4b71Sopenharmony_ci> 8e41f4b71Sopenharmony_ci> This component is supported since API version 12. Updates will be marked with a superscript to indicate their earliest API version. 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## Child Components 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ciSupported 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ciSince API version 10, you are advised to use [NavPathStack](ts-basic-components-navigation.md#navpathstack10) for page routing. 15e41f4b71Sopenharmony_ci 16e41f4b71Sopenharmony_ci## AtomicServiceNavigation 17e41f4b71Sopenharmony_ci 18e41f4b71Sopenharmony_ciAtomicServiceNavigation({ 19e41f4b71Sopenharmony_ci navPathStack?: NavPathStack, 20e41f4b71Sopenharmony_ci navigationContent: Callback\<void\>, 21e41f4b71Sopenharmony_ci title?: ResourceStr, 22e41f4b71Sopenharmony_ci titleBackgroundColor?: ResourceColor, 23e41f4b71Sopenharmony_ci hideTitleBar?: boolean, 24e41f4b71Sopenharmony_ci navBarWidth?: Length, 25e41f4b71Sopenharmony_ci mode?: NavigationMode, 26e41f4b71Sopenharmony_ci navDestinationBuilder?: NavDestinationBuilder, 27e41f4b71Sopenharmony_ci navBarWidthRange?: [Dimension, Dimension], 28e41f4b71Sopenharmony_ci minContentWidth?: Dimension, 29e41f4b71Sopenharmony_ci stateChangeCallback?: Callback\<boolean\>, 30e41f4b71Sopenharmony_ci modeChangeCallback?: Callback\<NavigationMode\> 31e41f4b71Sopenharmony_ci}) 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci**Decorator**: @Component 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 38e41f4b71Sopenharmony_ci 39e41f4b71Sopenharmony_ci**Parameters** 40e41f4b71Sopenharmony_ci 41e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Decorator|Description | 42e41f4b71Sopenharmony_ci| --------------- | ------ | ---- | ----|----------| 43e41f4b71Sopenharmony_ci| navPathStack | [NavPathStack](ts-basic-components-navigation.md#navpathstack10) | No | @State | Information about the navigation stack. | 44e41f4b71Sopenharmony_ci| navigationContent | Callback\<void\> | No | @BuilderParam | Content of the navigation container. | 45e41f4b71Sopenharmony_ci| title | [ResourceStr](ts-types.md#resourcestr) | No |@Prop | Page title.| 46e41f4b71Sopenharmony_ci| titleOptions | [TitleOptions](#titleoptions) | No | @Prop | Title bar options.| 47e41f4b71Sopenharmony_ci| hideTitleBar | boolean | No | @Prop | Whether to hide the title bar.| 48e41f4b71Sopenharmony_ci| navBarWidth | [Length](ts-types.md#length)| No | @Prop | Width of the navigation bar.<br>This attribute takes effect only when the component is split.| 49e41f4b71Sopenharmony_ci| mode| [NavigationMode](ts-basic-components-navigation.md#navigationmode9) | No | @Prop |Display mode of the navigation bar.<br>Available options are **Stack**, **Split**, and **Auto**.| 50e41f4b71Sopenharmony_ci| navDestinationBuilder | [NavDestinationBuilder](#navdestinationbuilder) | No | @BuilderParam | Builder data required for creating the [NavDestination](ts-basic-components-navdestination.md) component. | 51e41f4b71Sopenharmony_ci| navBarWidthRange | [[Dimension](ts-types.md#dimension10), [Dimension](ts-types.md#dimension10)] | No | @Prop |Minimum and maximum widths of the navigation bar (effective in dual-column mode).| 52e41f4b71Sopenharmony_ci| minContentWidth | [Dimension](ts-types.md#dimension10) | No | @Prop | Minimum width of the navigation bar content area (effective in dual-column mode).| 53e41f4b71Sopenharmony_ci| stateChangeCallback | Callback\<boolean\> | No | - | Callback invoked when the navigation bar visibility status changes.| 54e41f4b71Sopenharmony_ci| modeChangeCallback | Callback\<[NavigationMode](ts-basic-components-navigation.md#navigationmode9)\> | No | - | Callback invoked when the component is displayed for the first time or its display mode switches between single-column and dual-column.| 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci## TitleOptions 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 61e41f4b71Sopenharmony_ci 62e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 63e41f4b71Sopenharmony_ci| --------------- | ------ | ---- | ---------- | 64e41f4b71Sopenharmony_ci| backgroundColor | [ResourceColor](ts-types.md#resourcecolor) | No | Background color of the title bar. | 65e41f4b71Sopenharmony_ci| isBlurEnabled | boolean | No | Whether the title bar is blurred.<br>Default value: **true** | 66e41f4b71Sopenharmony_ci| TitleOptions | [BarStyle<sup>12+</sup>](ts-basic-components-navigation.md#barstyle12) | No | Style options of the title bar. | 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci## NavDestinationBuilder 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 71e41f4b71Sopenharmony_ci 72e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 73e41f4b71Sopenharmony_ci 74e41f4b71Sopenharmony_ci| Name | Type | Mandatory | Description | 75e41f4b71Sopenharmony_ci| --------------- | ------ | ---- | ---------- | 76e41f4b71Sopenharmony_ci| name | string | Yes | Name of the [NavDestination](ts-basic-components-navdestination.md) page. | 77e41f4b71Sopenharmony_ci| param | Object | Yes | Settings of the [NavDestination](ts-basic-components-navdestination.md) page. | 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ci## Example 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci```ts 82e41f4b71Sopenharmony_ci// Index.ets 83e41f4b71Sopenharmony_ciimport { AtomicServiceNavigation, NavDestinationBuilder, AtomicServiceTabs, TabBarOptions, TabBarPosition } from '@kit.ArkUI'; 84e41f4b71Sopenharmony_ci 85e41f4b71Sopenharmony_ci@Entry 86e41f4b71Sopenharmony_ci@Component 87e41f4b71Sopenharmony_cistruct Index { 88e41f4b71Sopenharmony_ci @State message: string = 'Title'; 89e41f4b71Sopenharmony_ci childNavStack: NavPathStack = new NavPathStack(); 90e41f4b71Sopenharmony_ci @Builder 91e41f4b71Sopenharmony_ci tabContent1() { 92e41f4b71Sopenharmony_ci Text('first page') 93e41f4b71Sopenharmony_ci .onClick(() => { 94e41f4b71Sopenharmony_ci this.childNavStack.pushPath({ name: 'page one' }) 95e41f4b71Sopenharmony_ci }) 96e41f4b71Sopenharmony_ci } 97e41f4b71Sopenharmony_ci 98e41f4b71Sopenharmony_ci @Builder 99e41f4b71Sopenharmony_ci tabContent2() { 100e41f4b71Sopenharmony_ci Text('second page') 101e41f4b71Sopenharmony_ci } 102e41f4b71Sopenharmony_ci 103e41f4b71Sopenharmony_ci @Builder 104e41f4b71Sopenharmony_ci tabContent3() { 105e41f4b71Sopenharmony_ci Text('third page') 106e41f4b71Sopenharmony_ci } 107e41f4b71Sopenharmony_ci 108e41f4b71Sopenharmony_ci @Builder 109e41f4b71Sopenharmony_ci navigationContent() { 110e41f4b71Sopenharmony_ci AtomicServiceTabs({ 111e41f4b71Sopenharmony_ci tabContents: [ 112e41f4b71Sopenharmony_ci () => { 113e41f4b71Sopenharmony_ci this.tabContent1() 114e41f4b71Sopenharmony_ci }, 115e41f4b71Sopenharmony_ci () => { 116e41f4b71Sopenharmony_ci this.tabContent2() 117e41f4b71Sopenharmony_ci }, 118e41f4b71Sopenharmony_ci () => { 119e41f4b71Sopenharmony_ci this.tabContent3() 120e41f4b71Sopenharmony_ci } 121e41f4b71Sopenharmony_ci ], 122e41f4b71Sopenharmony_ci tabBarOptionsArray: [ 123e41f4b71Sopenharmony_ci new TabBarOptions($r('sys.media.ohos_ic_public_phone'), 'Feature 1'), 124e41f4b71Sopenharmony_ci new TabBarOptions($r('sys.media.ohos_ic_public_location'), 'Feature 2', Color.Green, Color.Red), 125e41f4b71Sopenharmony_ci new TabBarOptions($r('sys.media.ohos_ic_public_more'), 'Feature 3') 126e41f4b71Sopenharmony_ci ], 127e41f4b71Sopenharmony_ci tabBarPosition: TabBarPosition.BOTTOM, 128e41f4b71Sopenharmony_ci barBackgroundColor: $r('sys.color.ohos_id_color_bottom_tab_bg'), 129e41f4b71Sopenharmony_ci onTabBarClick: (index: Number) => { 130e41f4b71Sopenharmony_ci if (index == 0) { 131e41f4b71Sopenharmony_ci this.message = 'Feature 1'; 132e41f4b71Sopenharmony_ci } else if (index == 1) { 133e41f4b71Sopenharmony_ci this.message = 'Feature 2'; 134e41f4b71Sopenharmony_ci } else { 135e41f4b71Sopenharmony_ci this.message = 'Feature 3'; 136e41f4b71Sopenharmony_ci } 137e41f4b71Sopenharmony_ci } 138e41f4b71Sopenharmony_ci }) 139e41f4b71Sopenharmony_ci } 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci @Builder 142e41f4b71Sopenharmony_ci pageMap(name: string) { 143e41f4b71Sopenharmony_ci if (name === 'page one') { 144e41f4b71Sopenharmony_ci PageOne() 145e41f4b71Sopenharmony_ci } else if (name === 'page two') { 146e41f4b71Sopenharmony_ci PageTwo() 147e41f4b71Sopenharmony_ci } 148e41f4b71Sopenharmony_ci } 149e41f4b71Sopenharmony_ci 150e41f4b71Sopenharmony_ci build() { 151e41f4b71Sopenharmony_ci Row() { 152e41f4b71Sopenharmony_ci Column() { 153e41f4b71Sopenharmony_ci AtomicServiceNavigation({ 154e41f4b71Sopenharmony_ci navigationContent: () => { 155e41f4b71Sopenharmony_ci this.navigationContent() 156e41f4b71Sopenharmony_ci }, 157e41f4b71Sopenharmony_ci title: this.message, 158e41f4b71Sopenharmony_ci titleOptions: { 159e41f4b71Sopenharmony_ci backgroundColor: 'rgb(61, 157, 180)', 160e41f4b71Sopenharmony_ci isBlurEnabled: false 161e41f4b71Sopenharmony_ci }, 162e41f4b71Sopenharmony_ci navDestinationBuilder: this.pageMap, 163e41f4b71Sopenharmony_ci navPathStack: this.childNavStack, 164e41f4b71Sopenharmony_ci mode: NavigationMode.Stack 165e41f4b71Sopenharmony_ci }) 166e41f4b71Sopenharmony_ci } 167e41f4b71Sopenharmony_ci .width('100%') 168e41f4b71Sopenharmony_ci } 169e41f4b71Sopenharmony_ci .height('100%') 170e41f4b71Sopenharmony_ci } 171e41f4b71Sopenharmony_ci} 172e41f4b71Sopenharmony_ci 173e41f4b71Sopenharmony_ci@Component 174e41f4b71Sopenharmony_ciexport struct PageOne { 175e41f4b71Sopenharmony_ci pageInfo: NavPathStack = new NavPathStack(); 176e41f4b71Sopenharmony_ci 177e41f4b71Sopenharmony_ci build() { 178e41f4b71Sopenharmony_ci NavDestination() { 179e41f4b71Sopenharmony_ci Button('Next') 180e41f4b71Sopenharmony_ci .onClick(() => { 181e41f4b71Sopenharmony_ci this.pageInfo.pushPath({ name: 'page two'}) 182e41f4b71Sopenharmony_ci }) 183e41f4b71Sopenharmony_ci } 184e41f4b71Sopenharmony_ci .title('PageOne') 185e41f4b71Sopenharmony_ci .onReady((context: NavDestinationContext) => { 186e41f4b71Sopenharmony_ci this.pageInfo = context.pathStack; 187e41f4b71Sopenharmony_ci }) 188e41f4b71Sopenharmony_ci } 189e41f4b71Sopenharmony_ci} 190e41f4b71Sopenharmony_ci 191e41f4b71Sopenharmony_ci@Component 192e41f4b71Sopenharmony_ciexport struct PageTwo { 193e41f4b71Sopenharmony_ci pageInfo: NavPathStack = new NavPathStack(); 194e41f4b71Sopenharmony_ci 195e41f4b71Sopenharmony_ci build() { 196e41f4b71Sopenharmony_ci NavDestination() { 197e41f4b71Sopenharmony_ci Button('End') 198e41f4b71Sopenharmony_ci } 199e41f4b71Sopenharmony_ci .title('PageTwo') 200e41f4b71Sopenharmony_ci .onReady((context: NavDestinationContext) => { 201e41f4b71Sopenharmony_ci this.pageInfo = context.pathStack; 202e41f4b71Sopenharmony_ci }) 203e41f4b71Sopenharmony_ci } 204e41f4b71Sopenharmony_ci} 205e41f4b71Sopenharmony_ci``` 206e41f4b71Sopenharmony_ci 207e41f4b71Sopenharmony_ci 208