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