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