• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# TabContent
2
3The **TabContent** component is used only in the **Tabs** component. It corresponds to the content view of a switched tab page.
4
5>  **NOTE**
6>
7>  This component is supported since API version 7. Updates will be marked with a superscript to indicate their earliest API version.
8
9
10## Child Components
11
12This component supports only one child component.
13
14>  **NOTE**
15>
16>  Built-in components and custom components are allowed, with 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.
17
18
19## APIs
20
21TabContent()
22
23Creates the **TabContent** component, which represents the content associated with a specific tab.
24
25**Atomic service API**: This API can be used in atomic services since API version 11.
26
27**System capability**: SystemCapability.ArkUI.ArkUI.Full
28
29## Attributes
30
31In addition to the [universal attributes](ts-component-general-attributes.md), the following attributes are supported.
32
33### tabBar
34
35tabBar(options: string | Resource | CustomBuilder | TabBarOptions)
36
37Sets the content displayed on the tab bar.
38
39If an icon uses an SVG image, the width and height attributes of the SVG image must be deleted. Otherwise, the icon size will be determined by the width and height attributes of the SVG image.
40
41If the content set exceeds the space provided by the tab bar, it will be clipped.
42
43**Atomic service API**: This API can be used in atomic services since API version 11.
44
45**System capability**: SystemCapability.ArkUI.ArkUI.Full
46
47**Parameters**
48
49| Name| Type| Mandatory| Description|
50| -------- | -------- | -------- | -------- |
51| options | string \| [Resource](ts-types.md#resource) \|<br>[CustomBuilder](ts-types.md#custombuilder8)<sup>8+</sup>\| <br>[TabBarOptions](#tabbaroptions18)<sup>18+</sup> | Yes| Content displayed on the tab bar.<br>**CustomBuilder**: builder, to which components can be passed (applicable to API version 8 and later versions).|
52
53### tabBar<sup>9+</sup>
54
55tabBar(value: SubTabBarStyle | BottomTabBarStyle)
56
57Sets the content displayed on the tab bar. The bottom tab style does not include an indicator. When an icon display error occurs, a gray blank block is displayed.
58
59**Atomic service API**: This API can be used in atomic services since API version 11.
60
61**System capability**: SystemCapability.ArkUI.ArkUI.Full
62
63**Parameters**
64
65| Name| Type                                                        | Mandatory| Description                                                        |
66| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
67| value  | [SubTabBarStyle](#subtabbarstyle9) \| [BottomTabBarStyle](#bottomtabbarstyle9) | Yes  | Content displayed on the tab bar.<br>**SubTabBarStyle**: subtab style<br>**BottomTabBarStyle**: bottom and side tab style|
68
69### tabBar<sup>18+</sup>
70
71tabBar(content: ComponentContent | SubTabBarStyle | BottomTabBarStyle | string | Resource | CustomBuilder | TabBarOptions)
72
73Content displayed on the tab bar.
74
75If **BottomTabBarStyle** or **TabBarOptions** is used and an icon is set, a gray block will be displayed if the icon is invalid. If an icon is an SVG image, make sure the SVG image does not have its own width and height attributes. If the SVG image has embedded width and height attributes, the icon size will be determined by these attributes.
76
77If the content exceeds the space provided by the tab bar, it will be clipped.
78
79**Atomic service API**: This API can be used in atomic services since API version 18.
80
81**System capability**: SystemCapability.ArkUI.ArkUI.Full
82
83**Parameters**
84
85| Name | Type                                                        | Mandatory| Description                                                        |
86| ------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
87| content | [ComponentContent](../js-apis-arkui-ComponentContent.md) \|<br>[SubTabBarStyle](#subtabbarstyle9) \|[BottomTabBarStyle](#bottomtabbarstyle9) \|<br>string \| [Resource](ts-types.md#resource) \|<br>[CustomBuilder](ts-types.md#custombuilder8)\| <br>[TabBarOptions](#tabbaroptions18) | Yes  | Content displayed on the tab bar.<br>**ComponentContent**: encapsulation of the component content, which can be customized.<br>**SubTabBarStyle**: subtab style.<br>**BottomTabBarStyle**: style of the bottom and side tabs. The bottom style does not have the underline effect.<br>**string**: string type.<br>**Resource**: resource reference for importing strings from system or application resources.<br>**CustomBuilder**: builder that can take components as arguments.<br>**TabBarOptions**: options for configuring images and text content on the tabs.|
88
89>  **NOTE**
90>
91>  - The **TabContent** component does not support setting of the common width attribute. By default, its width is the same as that of the parent **Tabs** component.
92>  - The **TabContent** component does not support setting of the universal height attribute. Its height is determined by the height of the parent **Tabs** component and the **TabBar** component.
93>  - If the **vertical** attribute is **false**, the width and height descriptions are swapped in the preceding two restrictions.
94>  - **TabContent** does not support page scrolling. If page scrolling is required, consider nesting a list.
95>  - Whenever possible, use a unified parameter type for the **tabBar** property of all child **TabContent** components within the **Tabs** component.
96>  - If there are focusable components inside any **TabContent**, focus navigation between **TabContent** and **TabBar** components within the **Tabs** component is only supported using the keyboard arrow keys.
97
98## TabBarOptions<sup>18+</sup>
99
100Defines the options for configuring images and text content on the tabs.
101
102**Atomic service API**: This API can be used in atomic services since API version 18.
103
104**System capability**: SystemCapability.ArkUI.ArkUI.Full
105
106**Parameters**
107
108| Name| Type        | Mandatory| Description|
109| -------- | -------- | -------- | -------- |
110| icon<sup>7+</sup> | string \| [ResourceStr](ts-types.md#resourcestr) | No| Image for the tab.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
111| text<sup>7+</sup> | string \| [ResourceStr](ts-types.md#resourcestr) | No| Text for the tab.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
112
113## SubTabBarStyle<sup>9+</sup>
114
115Implements the subtab style. A transition animation is played when the user switches between tabs.
116
117### constructor
118
119constructor(content: ResourceStr)
120
121Constructor used to create a **SubTabBarStyle** instance.
122
123**Atomic service API**: This API can be used in atomic services since API version 11.
124
125**System capability**: SystemCapability.ArkUI.ArkUI.Full
126
127**Parameters**
128
129| Name| Type        | Mandatory| Description|
130| -------- | -------- | -------- | -------- |
131| content | [ResourceStr](ts-types.md#resourcestr) | Yes| Text for the tab.|
132
133### constructor<sup>12+</sup>
134
135constructor(content: ResourceStr | ComponentContent)
136
137Constructor used to create a **SubTabBarStyle** instance. You can set custom content with **ComponentContent**.
138
139**Atomic service API**: This API can be used in atomic services since API version 12.
140
141**System capability**: SystemCapability.ArkUI.ArkUI.Full
142
143**Parameters**
144
145| Name| Type        | Mandatory| Description|
146| -------- | -------- | -------- | -------- |
147| content | [ResourceStr](ts-types.md#resourcestr) \| [ComponentContent](../js-apis-arkui-ComponentContent.md) | Yes| Content on the tab.<br>**NOTE**<br>1. Custom content does not support the **labelStyle** attribute.<br>2. If the custom content exceeds the content box of the tab page, the excess part is not displayed.<br>3. If the custom content is within the content box of the tab page, it is aligned in the center.<br>4. If the custom content is abnormal or no display component is available, a blank area is displayed.|
148
149### of<sup>10+</sup>
150
151static of(content: ResourceStr): SubTabBarStyle
152
153Static constructor used to create a **SubTabBarStyle** instance.
154
155**Atomic service API**: This API can be used in atomic services since API version 11.
156
157**System capability**: SystemCapability.ArkUI.ArkUI.Full
158
159**Parameters**
160
161| Name | Type                                  | Mandatory| Description          |
162| ------- | ------------------------------------------ | ---- | ------------------ |
163| content | [ResourceStr](ts-types.md#resourcestr) | Yes  | Text for the tab.|
164
165**Return value**
166
167| Type   | Description                                                        |
168| ------- | ------------------------------------------------------------ |
169| [SubTabBarStyle](#subtabbarstyle9) | **SubTabBarStyle** object created.|
170
171### of<sup>12+</sup>
172
173static of(content: ResourceStr | ComponentContent): SubTabBarStyle
174
175Static constructor used to create a **SubTabBarStyle** instance. You can set custom content with **ComponentContent**.
176
177**Atomic service API**: This API can be used in atomic services since API version 12.
178
179**System capability**: SystemCapability.ArkUI.ArkUI.Full
180
181**Parameters**
182
183| Name | Type                                  | Mandatory| Description          |
184| ------- | ------------------------------------------ | ---- | ------------------ |
185| content | [ResourceStr](ts-types.md#resourcestr) \| [ComponentContent](../js-apis-arkui-ComponentContent.md) | Yes  | Content on the tab. You can set custom content with **ComponentContent**.<br>**NOTE**<br>1. Custom content does not support the **labelStyle** attribute.<br>2. If the custom content exceeds the content box of the tab page, the excess part is not displayed.<br>3. If the custom content is within the content box of the tab page, it is aligned in the center.<br>4. If the custom content is abnormal or no display component is available, a blank area is displayed.|
186
187**Return value**
188
189| Type   | Description                                                        |
190| ------- | ------------------------------------------------------------ |
191| [SubTabBarStyle](#subtabbarstyle9) | **SubTabBarStyle** object created.|
192
193### indicator<sup>10+</sup>
194
195indicator(value: IndicatorStyle): SubTabBarStyle
196
197Sets the indicator style of the selected subtab. It takes effect only in the horizontal layout.
198
199**Atomic service API**: This API can be used in atomic services since API version 11.
200
201**System capability**: SystemCapability.ArkUI.ArkUI.Full
202
203**Parameters**
204
205| Name | Type                                  | Mandatory| Description          |
206| ------- | ------------------------------------- | ---- | ------------- |
207| value | [IndicatorStyle](#indicatorstyle10)| Yes  | Indicator style object for the selected subtab.|
208
209**Return value**
210
211| Type   | Description                                                        |
212| ------- | ------------------------------------------------------------ |
213| [SubTabBarStyle](#subtabbarstyle9) | **SubTabBarStyle** object.|
214
215### selectedMode<sup>10+</sup>
216
217selectedMode(value: SelectedMode): SubTabBarStyle
218
219Sets the display mode of the selected subtab. It takes effect only in the horizontal layout.
220
221**Atomic service API**: This API can be used in atomic services since API version 11.
222
223**System capability**: SystemCapability.ArkUI.ArkUI.Full
224
225**Parameters**
226
227| Name | Type                                  | Mandatory| Description          |
228| ------- | ------------------------------------- | ---- | ------------- |
229| value | [SelectedMode](#selectedmode10) | Yes  | Display mode of the selected subtab.<br>Default value: **SelectedMode.INDICATOR**|
230
231**Return value**
232
233| Type   | Description                                                        |
234| ------- | ------------------------------------------------------------ |
235| [SubTabBarStyle](#subtabbarstyle9) | **SubTabBarStyle** object.|
236
237### board<sup>10+</sup>
238
239board(value: BoardStyle): SubTabBarStyle
240
241Sets the background style (board style) of the selected subtab. It takes effect only in the horizontal layout.
242
243**Atomic service API**: This API can be used in atomic services since API version 11.
244
245**System capability**: SystemCapability.ArkUI.ArkUI.Full
246
247**Parameters**
248
249| Name | Type                                  | Mandatory| Description          |
250| ------- | ------------------------------------- | ---- | ------------- |
251| value | [BoardStyle](#boardstyle10) | Yes  | Background style object for the selected subtab.|
252
253**Return value**
254
255| Type   | Description                                                        |
256| ------- | ------------------------------------------------------------ |
257| [SubTabBarStyle](#subtabbarstyle9) | **SubTabBarStyle** object.|
258
259### labelStyle<sup>10+</sup>
260
261labelStyle(value: LabelStyle): SubTabBarStyle
262
263Sets the style of the label text and font for the subtab.
264
265**Atomic service API**: This API can be used in atomic services since API version 11.
266
267**System capability**: SystemCapability.ArkUI.ArkUI.Full
268
269**Parameters**
270
271| Name | Type                                  | Mandatory| Description          |
272| ------- | ------------------------------------- | ---- | ------------- |
273| value | [LabelStyle](#labelstyle10) | Yes  | Style object for the label text and font of the subtab.|
274
275**Return value**
276
277| Type   | Description                                                        |
278| ------- | ------------------------------------------------------------ |
279| [SubTabBarStyle](#subtabbarstyle9) | **SubTabBarStyle** object.|
280
281### padding<sup>10+</sup>
282
283padding(value: Padding | Dimension): SubTabBarStyle
284
285Sets the padding of the subtab. It cannot be set in percentage. When the parameter is of the Dimension type, the value applies to all sides.
286
287**Atomic service API**: This API can be used in atomic services since API version 11.
288
289**System capability**: SystemCapability.ArkUI.ArkUI.Full
290
291**Parameters**
292
293| Name | Type                                  | Mandatory| Description          |
294| ------- | ------------------------------------- | ---- | ------------- |
295| value | [Padding](ts-types.md#padding) \| [Dimension](ts-types.md#dimension10) | Yes  | Padding of the subtab.<br>Default value: **{left:8.0vp,right:8.0vp,top:17.0vp,bottom:18.0vp}**|
296
297**Return value**
298
299| Type   | Description                                                        |
300| ------- | ------------------------------------------------------------ |
301| [SubTabBarStyle](#subtabbarstyle9) | **SubTabBarStyle** object.|
302
303### padding<sup>12+</sup>
304
305padding(padding: LocalizedPadding): SubTabBarStyle
306
307Sets the padding of the subtab. This API supports mirroring but does not support percentage-based settings.
308
309**Atomic service API**: This API can be used in atomic services since API version 12.
310
311**System capability**: SystemCapability.ArkUI.ArkUI.Full
312
313**Parameters**
314
315| Name | Type                                  | Mandatory| Description          |
316| ------- | ------------------------------------- | ---- | ------------- |
317| padding | [LocalizedPadding](ts-types.md#localizedpadding12) | Yes  | Padding of the subtab.<br>Default value: {start:LengthMetircs.vp(8),end:LengthMetircs.vp(8),<br>top:LengthMetircs.vp(17),bottom:LengthMetircs.vp(18)} |
318
319**Return value**
320
321| Type   | Description                                                        |
322| ------- | ------------------------------------------------------------ |
323| [SubTabBarStyle](#subtabbarstyle9) | **SubTabBarStyle** object.|
324
325### id<sup>11+</sup>
326
327id(value: string): SubTabBarStyle
328
329Sets the [ID](ts-universal-attributes-component-id.md#id) of the subtab.
330
331**Atomic service API**: This API can be used in atomic services since API version 12.
332
333**System capability**: SystemCapability.ArkUI.ArkUI.Full
334
335**Parameters**
336
337| Name | Type                                  | Mandatory| Description          |
338| ------- | ------------------------------------- | ---- | ------------- |
339| value | string | Yes  | [ID](ts-universal-attributes-component-id.md#id) of the subtab.|
340
341**Return value**
342
343| Type   | Description                                                        |
344| ------- | ------------------------------------------------------------ |
345| [SubTabBarStyle](#subtabbarstyle9) | **SubTabBarStyle** object.|
346
347## IndicatorStyle<sup>10+</sup>
348
349Represents an indicator style object.
350
351**Atomic service API**: This API can be used in atomic services since API version 11.
352
353**System capability**: SystemCapability.ArkUI.ArkUI.Full
354
355| Name| Type| Mandatory| Description|
356| -------- | -------- | -------- | -------------------------------- |
357| color | [ResourceColor](ts-types.md#resourcecolor) | No| Color of the indicator and board.<br>Default value: **#FF007DFF**|
358| height | [Length](ts-types.md#length) | No| Height of the indicator. It cannot be set in percentage.<br>Default value: **2.0**<br>Unit: vp<br>Value range: (0, +∞)|
359| width | [Length](ts-types.md#length) | No| Width of the indicator. It cannot be set in percentage.<br>Default value: **0.0**<br>Unit: vp<br>Value range: (0, +∞)<br>**NOTE**<br>If this parameter is set to **0**, the tab text width will be used instead.|
360| borderRadius | [Length](ts-types.md#length) | No| Rounded corner radius of the indicator. It cannot be set in percentage.<br>Default value: **0.0**<br>Unit: vp<br>Value range: [0, +∞)|
361| marginTop | [Length](ts-types.md#length) | No| Spacing between the indicator and text. It cannot be set in percentage.<br>Default value: **8.0**<br>Unit: vp<br>Value range: [0, +∞)|
362
363## SelectedMode<sup>10+</sup>
364
365Enumerates the display modes of selected subtabs.
366
367**Atomic service API**: This API can be used in atomic services since API version 11.
368
369**System capability**: SystemCapability.ArkUI.ArkUI.Full
370
371| Name      | Description              |
372| ---------- | ------------------------ |
373| INDICATOR | Indicator mode.    |
374| BOARD   | Board mode.    |
375
376## BoardStyle<sup>10+</sup>
377
378Represents a board style object.
379
380**Atomic service API**: This API can be used in atomic services since API version 11.
381
382**System capability**: SystemCapability.ArkUI.ArkUI.Full
383
384| Name| Type| Mandatory| Description|
385| -------- | -------- | -------- | ------------------------------------ |
386| borderRadius | [Length](ts-types.md#length) | No| Rounded corner radius of the board. It cannot be set in percentage.<br>Default value: **8.0**<br>Unit: vp<br>Value range: [0, +∞)|
387
388## LabelStyle<sup>10+</sup>
389
390Represents a style object for the label text and font.
391
392**System capability**: SystemCapability.ArkUI.ArkUI.Full
393
394| Name                | Type                                                    | Mandatory| Description                                                        |
395| -------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
396| overflow             | [TextOverflow](ts-appendix-enums.md#textoverflow)            | No  | Display mode when the label text is too long. By default, an ellipsis (...) is used to represent text overflow.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
397| maxLines             | number                                                       | No  | Maximum number of lines in the label text. If this attribute is specified, the text will not exceed the specified number of lines. You can use **textOverflow** to specify how to represent text overflow. Default value: **1**<br>Value range: [1, +∞)<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
398| minFontSize          | number \| [ResourceStr](ts-types.md#resourcestr)             | No  | Minimum font size of the label text. It cannot be set in percentage. For the setting to take effect, this attribute must be used together with **maxFontSize**, **maxLines**, or layout constraint settings. When the adaptive text size is set, **font.size** does not take effect. The default value is **0.0fp**, indicating that the adaptive text size has no effect.<br>Value range: (0, +∞)<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
399| maxFontSize          | number \| [ResourceStr](ts-types.md#resourcestr)             | No  | Maximum font size of the label text. It cannot be set in percentage. For the setting to take effect, this attribute must be used together with **minFontSize**, **maxLines**, or layout constraint settings. When the adaptive text size is set, **font.size** does not take effect. The default value is **0.0fp**, indicating that the adaptive text size has no effect.<br>Value range: [minFontSize, +∞)<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
400| heightAdaptivePolicy | [TextHeightAdaptivePolicy](ts-appendix-enums.md#textheightadaptivepolicy10) | No  | How the adaptive height is determined for the label text. By default, the **maxLines** settings are prioritized.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
401| font                 | [Font](ts-types.md#font)                                     | No  | Font of the label text.<br>When the tab is a subtab, the default font is in 16.0 fp size, 'HarmonyOS Sans' family, normal font style, medium weight when selected, and normal weight when not selected.<br>When the tab is a bottom tab, the default font is in 10.0 fp size, 'HarmonyOS Sans' family, normal font style, and medium weight.<br>The default font size of the bottom tab page is 12.0 fp since API version 12.<br>**Atomic service API**: This API can be used in atomic services since API version 11.|
402| unselectedColor<sup>12+</sup> | [ResourceColor](ts-types.md#resourcecolor) | No| Font color of the label text when it is not selected.<br>Default value: **#99182431**<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
403| selectedColor<sup>12+</sup> | [ResourceColor](ts-types.md#resourcecolor) | No| Font color of the label text when it is selected.<br>Default value: **#FF007DFF**<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
404
405## BottomTabBarStyle<sup>9+</sup>
406
407Implements the bottom and side tab style.
408
409### constructor
410
411constructor(icon: ResourceStr | TabBarSymbol, text: ResourceStr)
412
413Constructor used to create a **BottomTabBarStyle** instance.
414
415**Atomic service API**: This API can be used in atomic services since API version 11.
416
417**System capability**: SystemCapability.ArkUI.ArkUI.Full
418
419**Parameters**
420
421| Name| Type        | Mandatory| Description|
422| -------- | -------- | -------- | -------- |
423| icon | [ResourceStr](ts-types.md#resourcestr) \| [TabBarSymbol<sup>12+</sup>](#tabbarsymbol12)| Yes| Image for the tab.|
424| text | [ResourceStr](ts-types.md#resourcestr) | Yes| Text for the tab.|
425
426### of<sup>10+</sup>
427
428static of(icon: ResourceStr | TabBarSymbol, text: ResourceStr): BottomTabBarStyle
429
430Static constructor used to create a **BottomTabBarStyle** instance.
431
432**Atomic service API**: This API can be used in atomic services since API version 11.
433
434**System capability**: SystemCapability.ArkUI.ArkUI.Full
435
436**Parameters**
437
438| Name| Type        | Mandatory| Description|
439| -------- | -------- | -------- | -------- |
440| icon | [ResourceStr](ts-types.md#resourcestr) \| [TabBarSymbol<sup>12+</sup>](#tabbarsymbol12)| Yes| Image for the tab.|
441| text | [ResourceStr](ts-types.md#resourcestr) | Yes| Text for the tab.|
442
443**Return value**
444
445| Type   | Description                                                        |
446| ------- | ------------------------------------------------------------ |
447| [BottomTabBarStyle](#bottomtabbarstyle9) | **BottomTabBarStyle** object created.|
448
449### padding<sup>10+</sup>
450
451padding(value: Padding | Dimension | LocalizedPadding): BottomTabBarStyle
452
453Sets the padding of the bottom tab. It cannot be set in percentage. When the parameter is of the Dimension type, the value applies to all sides.
454
455**Atomic service API**: This API can be used in atomic services since API version 11.
456
457**System capability**: SystemCapability.ArkUI.ArkUI.Full
458
459**Parameters**
460
461| Name | Type                                  | Mandatory| Description          |
462| ------- | ------------------------------------- | ---- | ------------- |
463| value | [Padding](ts-types.md#padding) \| [Dimension](ts-types.md#dimension10) \| [LocalizedPadding<sup>12+</sup>](ts-types.md#localizedpadding12) | Yes  | Padding of the bottom tab.<br>Default value: **{left:4.0vp,right:4.0vp,top:0.0vp,bottom:0.0vp}**<br>If of the LocalizedPadding type, this attribute supports the mirroring capability.<br>Default value: {start:LengthMetircs.vp(4),end:LengthMetircs.vp(4),<br>top:LengthMetircs.vp(0),bottom:LengthMetircs.vp(0)} |
464
465**Return value**
466
467| Type   | Description                                                        |
468| ------- | ------------------------------------------------------------ |
469| [BottomTabBarStyle](#bottomtabbarstyle9) | **BottomTabBarStyle** object.|
470
471### verticalAlign<sup>10+</sup>
472
473verticalAlign(value: VerticalAlign): BottomTabBarStyle
474
475Sets the vertical alignment mode of the images and text on the bottom tab.
476
477**Atomic service API**: This API can be used in atomic services since API version 11.
478
479**System capability**: SystemCapability.ArkUI.ArkUI.Full
480
481**Parameters**
482
483| Name | Type                                  | Mandatory| Description          |
484| ------- | ------------------------------------- | ---- | ------------- |
485| value | [VerticalAlign](ts-appendix-enums.md#verticalalign) | Yes  | Vertical alignment mode of the images and text on the bottom tab.<br>Default value: **VerticalAlign.Center**|
486
487**Return value**
488
489| Type   | Description                                                        |
490| ------- | ------------------------------------------------------------ |
491| [BottomTabBarStyle](#bottomtabbarstyle9) | **BottomTabBarStyle** object.|
492
493### layoutMode<sup>10+</sup>
494
495layoutMode(value: LayoutMode): BottomTabBarStyle
496
497Sets the layout mode of the images and texts on the bottom tab.
498
499**Atomic service API**: This API can be used in atomic services since API version 11.
500
501**System capability**: SystemCapability.ArkUI.ArkUI.Full
502
503**Parameters**
504
505| Name | Type                                  | Mandatory| Description          |
506| ------- | ------------------------------------- | ---- | ------------- |
507| value | [LayoutMode](#layoutmode10) | Yes  | Layout mode of the images and text on the bottom tab.<br>Default value: **LayoutMode.VERTICAL**|
508
509**Return value**
510
511| Type   | Description                                                        |
512| ------- | ------------------------------------------------------------ |
513| [BottomTabBarStyle](#bottomtabbarstyle9) | **BottomTabBarStyle** object.|
514
515### symmetricExtensible<sup>10+</sup>
516
517symmetricExtensible(value: boolean): BottomTabBarStyle
518
519Sets whether the images and text on the bottom tab can be symmetrically extended by the minimum value of the available space on the left and right bottom tabs. This parameter is valid only between bottom tabs in fixed horizontal mode.
520
521**Atomic service API**: This API can be used in atomic services since API version 11.
522
523**System capability**: SystemCapability.ArkUI.ArkUI.Full
524
525**Parameters**
526
527| Name | Type                                  | Mandatory| Description          |
528| ------- | ------------------------------------- | ---- | ------------- |
529| value | boolean | Yes  | Whether the images and text on the bottom tab can be symmetrically extended by the minimum value of the available space on the left and right bottom tabs.<br>Default value: **false**, indicating that the images and text on the bottom tab cannot be symmetrically extended by the minimum value of the available space on the left and right bottom tabs|
530
531**Return value**
532
533| Type   | Description                                                        |
534| ------- | ------------------------------------------------------------ |
535| [BottomTabBarStyle](#bottomtabbarstyle9) | **BottomTabBarStyle** object.|
536
537### labelStyle<sup>10+</sup>
538
539labelStyle(value: LabelStyle): BottomTabBarStyle
540
541Sets the style of the label text and font for the bottom tab.
542
543**Atomic service API**: This API can be used in atomic services since API version 11.
544
545**System capability**: SystemCapability.ArkUI.ArkUI.Full
546
547**Parameters**
548
549| Name | Type                                  | Mandatory| Description          |
550| ------- | ------------------------------------- | ---- | ------------- |
551| value | [LabelStyle](#labelstyle10) | Yes  | Style of the label text and font for the bottom tab.|
552
553**Return value**
554
555| Type   | Description                                                        |
556| ------- | ------------------------------------------------------------ |
557| [BottomTabBarStyle](#bottomtabbarstyle9) | **BottomTabBarStyle** object.|
558
559### id<sup>11+</sup>
560
561id(value: string): BottomTabBarStyle
562
563Sets the ID of the bottom tab.
564
565**Atomic service API**: This API can be used in atomic services since API version 12.
566
567**System capability**: SystemCapability.ArkUI.ArkUI.Full
568
569**Parameters**
570
571| Name | Type                                  | Mandatory| Description          |
572| ------- | ------------------------------------- | ---- | ------------- |
573| value | string | Yes  | [ID](ts-universal-attributes-component-id.md#id) of the bottom tab.|
574
575**Return value**
576
577| Type   | Description                                                        |
578| ------- | ------------------------------------------------------------ |
579| [BottomTabBarStyle](#bottomtabbarstyle9) | **BottomTabBarStyle** object.|
580
581### iconStyle<sup>12+</sup>
582
583iconStyle(style: TabBarIconStyle): BottomTabBarStyle
584
585Sets the style of the label icon on the bottom tab.
586
587**Atomic service API**: This API can be used in atomic services since API version 12.
588
589**System capability**: SystemCapability.ArkUI.ArkUI.Full
590
591**Parameters**
592
593| Name | Type                                  | Mandatory| Description          |
594| ------- | ------------------------------------- | ---- | ------------- |
595| style | [TabBarIconStyle](#tabbariconstyle12) | Yes  | Style of the label icon on the bottom tab.|
596
597**Return value**
598
599| Type   | Description                                                        |
600| ------- | ------------------------------------------------------------ |
601| [BottomTabBarStyle](#bottomtabbarstyle9) | **BottomTabBarStyle** object.|
602
603## TabBarSymbol<sup>12+</sup>
604
605Represents a tab bar symbol style object.
606
607**Atomic service API**: This API can be used in atomic services since API version 12.
608
609**System capability**: SystemCapability.ArkUI.ArkUI.Full
610
611| Name| Type        | Mandatory| Description|
612| -------- | -------- | -------- | -------- |
613| normal | [SymbolGlyphModifier](ts-universal-attributes-attribute-modifier.md) | Yes| Symbol icon in the normal style.<br>Default value:<br>**fontColor**: **#66182431**<br>**renderingStrategy**: **SymbolRenderingStrategy.MULTIPLE_OPACITY**<br>**fontSize**: **24vp**|
614| selected | [SymbolGlyphModifier](ts-universal-attributes-attribute-modifier.md) | No| Symbol icon in the selected style.<br>Default value:<br>**fontColor**: **#ff007dff**<br>**renderingStrategy**: **SymbolRenderingStrategy.MULTIPLE_OPACITY**<br>**fontSize**: **24vp**|
615
616## LayoutMode<sup>10+</sup>
617
618Enumerates the layout modes of the images and texts on the bottom tabs.
619
620**Atomic service API**: This API can be used in atomic services since API version 11.
621
622**System capability**: SystemCapability.ArkUI.ArkUI.Full
623
624| Name        | Value| Description                                    |
625| ----------  | - | ---------------------------------------- |
626| AUTO        | 0 | When the tab width is greater than 104 vp, the tab content is arranged from left to right. Otherwise,the tab content is arranged from top to bottom. This parameter is valid only when the tab bar is in vertical mode or fixed horizontal mode.|
627| VERTICAL    | 1 | The tab content is arranged from top to bottom.|
628| HORIZONTAL  | 2 | The tab content is arranged from left to right.|
629
630## TabBarIconStyle<sup>12+</sup>
631
632Represents a label icon style object.
633
634**Atomic service API**: This API can be used in atomic services since API version 12.
635
636**System capability**: SystemCapability.ArkUI.ArkUI.Full
637
638| Name                | Type                                                    | Mandatory| Description                                                        |
639| -------------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
640| unselectedColor | [ResourceColor](ts-types.md#resourcecolor) | No| Color of the label icon when it is not selected.<br>Default value: **#33182431**<br>**NOTE**<br>This attribute only applies to an SVG image. Once set, the fill color will replace that of the SVG image.|
641| selectedColor | [ResourceColor](ts-types.md#resourcecolor) | No| Color of the label icon when it is selected.<br>Default value: **#FF007DFF**<br>**NOTE**<br>This attribute only applies to an SVG image. Once set, the fill color will replace that of the SVG image.|
642
643## Events
644
645In addition to the [universal events](ts-component-general-events.md), the following events are supported.
646
647### onWillShow<sup>12+</sup>
648
649onWillShow(event: VoidCallback)
650
651Called when the tab content is about to be displayed. The scenarios include the first-time display, tab switching, page switching, and window switching between the foreground and background.
652
653**Atomic service API**: This API can be used in atomic services since API version 12.
654
655**System capability**: SystemCapability.ArkUI.ArkUI.Full
656
657**Parameters**
658
659| Name| Type                                          | Mandatory| Description                                |
660| ------ | --------------------------------------------- | ---- | ----------------------------------- |
661| event  | [VoidCallback](ts-types.md#voidcallback12)    | Yes  | Callback for when the tab content is about to be displayed.       |
662
663### onWillHide<sup>12+</sup>
664
665onWillHide(event: VoidCallback)
666
667Called when the tab content is about to be hidden. The scenarios include the tab switching, page switching, and window switching between the foreground and background.
668
669**Atomic service API**: This API can be used in atomic services since API version 12.
670
671**System capability**: SystemCapability.ArkUI.ArkUI.Full
672
673**Parameters**
674
675| Name| Type                                          | Mandatory| Description                                |
676| ------ | --------------------------------------------- | ---- | ----------------------------------- |
677| event  | [VoidCallback](ts-types.md#voidcallback12)    | Yes  | Callback for when the tab content is about to be hidden.       |
678
679## Example
680
681### Example 1: Implementing Custom Tab Switching Synchronization
682
683This example demonstrates how to use **onAnimationStart** and **onChange** to implement synchronized switching between the tab bar and tab content.
684
685```ts
686// xxx.ets
687@Entry
688@Component
689struct TabContentExample {
690  @State fontColor: string = '#182431'
691  @State selectedFontColor: string = '#007DFF'
692  @State currentIndex: number = 0
693  @State selectedIndex: number = 0
694  private controller: TabsController = new TabsController()
695
696  @Builder tabBuilder(index: number) {
697    Column() {
698      Image(this.selectedIndex === index ? '/common/public_icon_on.svg' : '/common/public_icon_off.svg')
699        .width(24)
700        .height(24)
701        .margin({ bottom: 4 })
702        .objectFit(ImageFit.Contain)
703      Text(`Tab${index + 1}`)
704        .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor)
705        .fontSize(10)
706        .fontWeight(500)
707        .lineHeight(14)
708    }.width('100%')
709  }
710
711  build() {
712    Column() {
713      Tabs({ barPosition: BarPosition.End, controller: this.controller }) {
714        TabContent() {
715          Column() {
716            Text('Tab1')
717              .fontSize(36)
718              .fontColor('#182431')
719              .fontWeight(500)
720              .opacity(0.4)
721              .margin({ top: 30, bottom: 56.5 })
722            Divider()
723              .strokeWidth(0.5)
724              .color('#182431')
725              .opacity(0.05)
726          }.width('100%')
727        }.tabBar(this.tabBuilder(0))
728
729        TabContent() {
730          Column() {
731            Text('Tab2')
732              .fontSize(36)
733              .fontColor('#182431')
734              .fontWeight(500)
735              .opacity(0.4)
736              .margin({ top: 30, bottom: 56.5 })
737            Divider()
738              .strokeWidth(0.5)
739              .color('#182431')
740              .opacity(0.05)
741          }.width('100%')
742        }.tabBar(this.tabBuilder(1))
743
744        TabContent() {
745          Column() {
746            Text('Tab3')
747              .fontSize(36)
748              .fontColor('#182431')
749              .fontWeight(500)
750              .opacity(0.4)
751              .margin({ top: 30, bottom: 56.5 })
752            Divider()
753              .strokeWidth(0.5)
754              .color('#182431')
755              .opacity(0.05)
756          }.width('100%')
757        }.tabBar(this.tabBuilder(2))
758
759        TabContent() {
760          Column() {
761            Text('Tab4')
762              .fontSize(36)
763              .fontColor('#182431')
764              .fontWeight(500)
765              .opacity(0.4)
766              .margin({ top: 30, bottom: 56.5 })
767            Divider()
768              .strokeWidth(0.5)
769              .color('#182431')
770              .opacity(0.05)
771          }.width('100%')
772        }.tabBar(this.tabBuilder(3))
773      }
774      .vertical(false)
775      .barHeight(56)
776      .onChange((index: number) => {
777        // currentIndex controls the displayed tab in TabContent.
778        this.currentIndex = index
779        this.selectedIndex = index
780      })
781      .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => {
782        if (index === targetIndex) {
783          return
784        }
785        // selectedIndex controls the color switching for the image and text in the custom tab bar.
786        this.selectedIndex = targetIndex
787      })
788      .width(360)
789      .height(190)
790      .backgroundColor('#F1F3F5')
791      .margin({ top: 38 })
792    }.width('100%')
793  }
794}
795```
796
797![tabContent](figures/tabContent1.gif)
798
799### Example 2: Implementing a Custom Side Tabs
800
801This example demonstrates how to create side tabs using **vertical** and **barPosition**.
802
803```ts
804// xxx.ets
805@Entry
806@Component
807struct TabContentExample {
808  @State fontColor: string = '#182431'
809  @State selectedFontColor: string = '#007DFF'
810  @State currentIndex: number = 0
811  @State selectedIndex: number = 0
812  private controller: TabsController = new TabsController()
813
814  @Builder tabBuilder(index: number) {
815    Column() {
816      Image(this.selectedIndex === index ? '/common/public_icon_on.svg' : '/common/public_icon_off.svg')
817        .width(24)
818        .height(24)
819        .margin({ bottom: 4 })
820        .objectFit(ImageFit.Contain)
821      Text('Tab')
822        .fontColor(this.selectedIndex === index ? this.selectedFontColor : this.fontColor)
823        .fontSize(10)
824        .fontWeight(500)
825        .lineHeight(14)
826    }.width('100%').height('100%').justifyContent(FlexAlign.Center)
827  }
828
829  build() {
830    Column() {
831      Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
832        TabContent()
833          .tabBar(this.tabBuilder(0))
834        TabContent()
835          .tabBar(this.tabBuilder(1))
836        TabContent()
837          .tabBar(this.tabBuilder(2))
838        TabContent()
839          .tabBar(this.tabBuilder(3))
840      }
841      .vertical(true)
842      .barWidth(96)
843      .barHeight(414)
844      .onChange((index: number) => {
845        // currentIndex controls the displayed tab in TabContent.
846        this.currentIndex = index
847        this.selectedIndex = index
848      })
849      .onAnimationStart((index: number, targetIndex: number, event: TabsAnimationEvent) => {
850        if (index === targetIndex) {
851          return
852        }
853        // selectedIndex controls the color switching for the image and text in the custom tab bar.
854        this.selectedIndex = targetIndex
855      })
856      .width(96)
857      .height(414)
858      .backgroundColor('#F1F3F5')
859      .margin({ top: 52 })
860    }.width('100%')
861  }
862}
863```
864
865![tabContent](figures/tabContent2.gif)
866
867### Example 3: Implementing Different Styles of Tabs
868
869This example demonstrates the implementation of subtabs, bottom tabs, and side tabs using **SubTabBarStyle** and **BottomTabBarStyle**.
870
871```ts
872// xxx.ets
873@Entry
874@Component
875struct TabBarStyleExample {
876  build() {
877    Column({ space: 5 }) {
878      Text("Subtab style")
879      Column() {
880        Tabs({ barPosition: BarPosition.Start }) {
881          TabContent() {
882            Column().width('100%').height('100%').backgroundColor(Color.Pink)
883          }.tabBar(new SubTabBarStyle('Pink'))
884          .onWillShow(() => {
885            console.info("Pink will show")
886          })
887          .onWillHide(() => {
888            console.info("Pink will hide")
889          })
890
891          TabContent() {
892            Column().width('100%').height('100%').backgroundColor(Color.Yellow)
893          }.tabBar(new SubTabBarStyle('Yellow'))
894          .onWillShow(() => {
895            console.info("Yellow will show")
896          })
897          .onWillHide(() => {
898            console.info("Yellow will hide")
899          })
900
901          TabContent() {
902            Column().width('100%').height('100%').backgroundColor(Color.Blue)
903          }.tabBar(new SubTabBarStyle('Blue'))
904          .onWillShow(() => {
905            console.info("Blue will show")
906          })
907          .onWillHide(() => {
908            console.info("Blue will hide")
909          })
910
911          TabContent() {
912            Column().width('100%').height('100%').backgroundColor(Color.Green)
913          }.tabBar(new SubTabBarStyle('Green'))
914          .onWillShow(() => {
915            console.info("Green will show")
916          })
917          .onWillHide(() => {
918            console.info("Green will hide")
919          })
920        }
921        .vertical(false)
922        .scrollable(true)
923        .barMode(BarMode.Fixed)
924        .onChange((index: number) => {
925          console.info(index.toString())
926        })
927        .width('100%')
928        .backgroundColor(0xF1F3F5)
929      }.width('100%').height(200)
930      Text("Bottom tab style")
931      Column() {
932        Tabs({ barPosition: BarPosition.End }) {
933          TabContent() {
934            Column().width('100%').height('100%').backgroundColor(Color.Pink)
935          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink'))
936          .onWillShow(() => {
937            console.info("Pink will show")
938          })
939          .onWillHide(() => {
940            console.info("Pink will hide")
941          })
942
943          TabContent() {
944            Column().width('100%').height('100%').backgroundColor(Color.Yellow)
945          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow'))
946          .onWillShow(() => {
947            console.info("Yellow will show")
948          })
949          .onWillHide(() => {
950            console.info("Yellow will hide")
951          })
952
953          TabContent() {
954            Column().width('100%').height('100%').backgroundColor(Color.Blue)
955          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue'))
956          .onWillShow(() => {
957            console.info("Blue will show")
958          })
959          .onWillHide(() => {
960            console.info("Blue will hide")
961          })
962
963          TabContent() {
964            Column().width('100%').height('100%').backgroundColor(Color.Green)
965          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green'))
966          .onWillShow(() => {
967            console.info("Green will show")
968          })
969          .onWillHide(() => {
970            console.info("Green will hide")
971          })
972        }
973        .vertical(false)
974        .scrollable(true)
975        .barMode(BarMode.Fixed)
976        .onChange((index: number) => {
977          console.info(index.toString())
978        })
979        .width('100%')
980        .backgroundColor(0xF1F3F5)
981      }.width('100%').height(200)
982      Text("Side tab style")
983      Column() {
984        Tabs({ barPosition: BarPosition.Start }) {
985          TabContent() {
986            Column().width('100%').height('100%').backgroundColor(Color.Pink)
987          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Pink'))
988          .onWillShow(() => {
989            console.info("Pink will show")
990          })
991          .onWillHide(() => {
992            console.info("Pink will hide")
993          })
994
995          TabContent() {
996            Column().width('100%').height('100%').backgroundColor(Color.Yellow)
997          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Yellow'))
998          .onWillShow(() => {
999            console.info("Yellow will show")
1000          })
1001          .onWillHide(() => {
1002            console.info("Yellow will hide")
1003          })
1004
1005          TabContent() {
1006            Column().width('100%').height('100%').backgroundColor(Color.Blue)
1007          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Blue'))
1008          .onWillShow(() => {
1009            console.info("Blue will show")
1010          })
1011          .onWillHide(() => {
1012            console.info("Blue will hide")
1013          })
1014
1015          TabContent() {
1016            Column().width('100%').height('100%').backgroundColor(Color.Green)
1017          }.tabBar(new BottomTabBarStyle($r('sys.media.ohos_app_icon'), 'Green'))
1018          .onWillShow(() => {
1019            console.info("Green will show")
1020          })
1021          .onWillHide(() => {
1022            console.info("Green will hide")
1023          })
1024        }
1025        .vertical(true).scrollable(true).barMode(BarMode.Fixed)
1026        .onChange((index: number) => {
1027          console.info(index.toString())
1028        })
1029        .width('100%')
1030        .backgroundColor(0xF1F3F5)
1031      }.width('100%').height(400)
1032    }
1033  }
1034}
1035```
1036
1037![tabbarStyle](figures/TabBarStyle.jpeg)
1038
1039### Example 4: Setting the Indicator for Subtabs
1040
1041This example demonstrates how to set the indicator for subtabs using the **indicator** property in **SubTabBarStyle**.
1042
1043```ts
1044// xxx.ets
1045@Entry
1046@Component
1047struct TabsAttr {
1048  private controller: TabsController = new TabsController()
1049  @State indicatorColor: Color = Color.Blue;
1050  @State indicatorWidth: number = 40;
1051  @State indicatorHeight: number = 10;
1052  @State indicatorBorderRadius: number = 5;
1053  @State indicatorSpace: number = 10;
1054  @State subTabBorderRadius: number = 20;
1055  @State selectedMode: SelectedMode = SelectedMode.INDICATOR;
1056  private colorFlag: boolean = true;
1057  private widthFlag: boolean = true;
1058  private heightFlag: boolean = true;
1059  private borderFlag: boolean = true;
1060  private spaceFlag: boolean = true;
1061
1062  build() {
1063    Column() {
1064      Button("Change Indicator Color").width('100%').margin({ bottom: '12vp' })
1065        .onClick((event?: ClickEvent) => {
1066          // Animation configuration for the width and height attributes of the <Button> component
1067          if (this.colorFlag) {
1068            animateTo({
1069              duration: 1000, // Animation duration.
1070              curve: Curve.Linear, // Animation curve.
1071              delay: 200, // Animation delay.
1072              iterations: 1, // Number of playback times.
1073              playMode: PlayMode.Normal, // Animation playback mode.
1074              onFinish: () => {
1075                console.info('play end')
1076              }
1077            }, () => {
1078              this.indicatorColor = Color.Red
1079            })
1080          } else {
1081            animateTo({
1082              duration: 1000, // Animation duration.
1083              curve: Curve.Linear, // Animation curve.
1084              delay: 200, // Animation delay.
1085              iterations: 1, // Number of playback times.
1086              playMode: PlayMode.Normal, // Animation playback mode.
1087              onFinish: () => {
1088                console.info('play end')
1089              }
1090            }, () => {
1091              this.indicatorColor = Color.Yellow
1092            })
1093          }
1094          this.colorFlag = !this.colorFlag
1095        })
1096      Button("Change Indicator Height").width('100%').margin({ bottom: '12vp' })
1097        .onClick((event?: ClickEvent) => {
1098          // Animation configuration for the width and height attributes of the <Button> component
1099          if (this.heightFlag) {
1100            animateTo({
1101              duration: 1000, // Animation duration.
1102              curve: Curve.Linear, // Animation curve.
1103              delay: 200, // Animation delay.
1104              iterations: 1, // Number of playback times.
1105              playMode: PlayMode.Normal, // Animation playback mode.
1106              onFinish: () => {
1107                console.info('play end')
1108              }
1109            }, () => {
1110              this.indicatorHeight = 20
1111            })
1112          } else {
1113            animateTo({
1114              duration: 1000, // Animation duration.
1115              curve: Curve.Linear, // Animation curve.
1116              delay: 200, // Animation delay.
1117              iterations: 1, // Number of playback times.
1118              playMode: PlayMode.Normal, // Animation playback mode.
1119              onFinish: () => {
1120                console.info('play end')
1121              }
1122            }, () => {
1123              this.indicatorHeight = 10
1124            })
1125          }
1126          this.heightFlag = !this.heightFlag
1127        })
1128      Button("Change Indicator Width").width('100%').margin({ bottom: '12vp' })
1129        .onClick((event?: ClickEvent) => {
1130          // Animation configuration for the width and height attributes of the <Button> component
1131          if (this.widthFlag) {
1132            animateTo({
1133              duration: 1000, // Animation duration.
1134              curve: Curve.Linear, // Animation curve.
1135              delay: 200, // Animation delay.
1136              iterations: 1, // Number of playback times.
1137              playMode: PlayMode.Normal, // Animation playback mode.
1138              onFinish: () => {
1139                console.info('play end')
1140              }
1141            }, () => {
1142              this.indicatorWidth = 30
1143            })
1144          } else {
1145            animateTo({
1146              duration: 1000, // Animation duration.
1147              curve: Curve.Linear, // Animation curve.
1148              delay: 200, // Animation delay.
1149              iterations: 1, // Number of playback times.
1150              playMode: PlayMode.Normal, // Animation playback mode.
1151              onFinish: () => {
1152                console.info('play end')
1153              }
1154            }, () => {
1155              this.indicatorWidth = 50
1156            })
1157          }
1158          this.widthFlag = !this.widthFlag
1159        })
1160      Button("Change Indicator Corner Radius").width('100%').margin({ bottom: '12vp' })
1161        .onClick((event?: ClickEvent) => {
1162          // Animation configuration for the width and height attributes of the <Button> component
1163          if (this.borderFlag) {
1164            animateTo({
1165              duration: 1000, // Animation duration.
1166              curve: Curve.Linear, // Animation curve.
1167              delay: 200, // Animation delay.
1168              iterations: 1, // Number of playback times.
1169              playMode: PlayMode.Normal, // Animation playback mode.
1170              onFinish: () => {
1171                console.info('play end')
1172              }
1173            }, () => {
1174              this.indicatorBorderRadius = 0
1175            })
1176          } else {
1177            animateTo({
1178              duration: 1000, // Animation duration.
1179              curve: Curve.Linear, // Animation curve.
1180              delay: 200, // Animation delay.
1181              iterations: 1, // Number of playback times.
1182              playMode: PlayMode.Normal, // Animation playback mode.
1183              onFinish: () => {
1184                console.info('play end')
1185              }
1186            }, () => {
1187              this.indicatorBorderRadius = 5
1188            })
1189          }
1190          this.borderFlag = !this.borderFlag
1191        })
1192      Button("Change Indicator Spacing").width('100%').margin({ bottom: '12vp' })
1193        .onClick((event?: ClickEvent) => {
1194          // Animation configuration for the width and height attributes of the <Button> component
1195          if (this.spaceFlag) {
1196            animateTo({
1197              duration: 1000, // Animation duration.
1198              curve: Curve.Linear, // Animation curve.
1199              delay: 200, // Animation delay.
1200              iterations: 1, // Number of playback times.
1201              playMode: PlayMode.Normal, // Animation playback mode.
1202              onFinish: () => {
1203                console.info('play end')
1204              }
1205            }, () => {
1206              this.indicatorSpace = 20
1207            })
1208          } else {
1209            animateTo({
1210              duration: 1000, // Animation duration.
1211              curve: Curve.Linear, // Animation curve.
1212              delay: 200, // Animation delay.
1213              iterations: 1, // Number of playback times.
1214              playMode: PlayMode.Normal, // Animation playback mode.
1215              onFinish: () => {
1216                console.info('play end')
1217              }
1218            }, () => {
1219              this.indicatorSpace = 10
1220            })
1221          }
1222          this.spaceFlag = !this.spaceFlag
1223        })
1224      Tabs({ barPosition: BarPosition.End, controller: this.controller }) {
1225        TabContent() {
1226          Column().width('100%').height('100%').backgroundColor(Color.Pink).borderRadius('12vp')
1227        }.tabBar(SubTabBarStyle.of('pink')
1228          .indicator({
1229            color: this.indicatorColor, // Indicator color.
1230            height: this.indicatorHeight, // Indicator height.
1231            width: this.indicatorWidth, // Indicator width.
1232            borderRadius: this.indicatorBorderRadius, // Rounded corner radius of the indicator.
1233            marginTop: this.indicatorSpace // Spacing between the indicator and text.
1234          })
1235          .selectedMode(this.selectedMode)
1236          .board({ borderRadius: this.subTabBorderRadius })
1237          .labelStyle({})
1238        )
1239
1240        TabContent() {
1241          Column().width('100%').height('100%').backgroundColor(Color.Yellow).borderRadius('12vp')
1242        }.tabBar('yellow')
1243
1244        TabContent() {
1245          Column().width('100%').height('100%').backgroundColor(Color.Blue).borderRadius('12vp')
1246        }.tabBar('blue')
1247
1248        TabContent() {
1249          Column().width('100%').height('100%').backgroundColor(Color.Green).borderRadius('12vp')
1250        }.tabBar('green')
1251
1252        TabContent() {
1253          Column().width('100%').height('100%').backgroundColor(Color.Gray).borderRadius('12vp')
1254        }.tabBar('gray')
1255
1256        TabContent() {
1257          Column().width('100%').height('100%').backgroundColor(Color.Orange).borderRadius('12vp')
1258        }.tabBar('orange')
1259      }
1260      .vertical(false)
1261      .scrollable(true)
1262      .barMode(BarMode.Scrollable)
1263      .barHeight(140)
1264      .animationDuration(400)
1265      .onChange((index: number) => {
1266        console.info(index.toString())
1267      })
1268      .backgroundColor(0xF5F5F5)
1269      .height(320)
1270    }.width('100%').height(250).padding({ top: '24vp', left: '24vp', right: '24vp' })
1271  }
1272}
1273```
1274
1275![tabContent3](figures/tabContent3.gif)
1276
1277### Example 5: Setting Adaptive Height for Subtab Text
1278
1279This example demonstrates how to achieve adaptive height for subtab text using **heightAdaptivePolicy**.
1280
1281```ts
1282// xxx.ets
1283@Entry
1284@Component
1285struct TabsTextOverflow {
1286  @State message: string = 'Hello World'
1287  private controller: TabsController = new TabsController()
1288  @State subTabOverflowOpaque: boolean = true;
1289
1290  build() {
1291    Column() {
1292      Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
1293        TabContent() {
1294          Column() {
1295            Text('Use an ellipsis').fontSize(30).fontColor(0xFF000000)
1296          }.width('100%').height('100%').backgroundColor(Color.Pink)
1297        }
1298        .tabBar(SubTabBarStyle.of('Start [Use an ellipsis; Use an ellipsis] End')
1299          .labelStyle({
1300            overflow: TextOverflow.Ellipsis,
1301            maxLines: 1,
1302            minFontSize: 10,
1303            heightAdaptivePolicy: TextHeightAdaptivePolicy.MAX_LINES_FIRST,
1304            font: { size: 20 }
1305          }))
1306
1307        TabContent() {
1308          Column() {
1309            Text('Scale down and then clip').fontSize(30).fontColor(0xFF000000)
1310          }.width('100%').height('100%').backgroundColor(Color.Pink)
1311        }
1312        .tabBar(SubTabBarStyle.of('Start [Scale down and then clip; Scale down and then clip] End')
1313          .labelStyle({
1314            overflow: TextOverflow.Clip,
1315            maxLines: 1,
1316            minFontSize: 15,
1317            maxFontSize: 15,
1318            heightAdaptivePolicy: TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST,
1319            font: { size: 20 }
1320          }))
1321
1322        TabContent() {
1323          Column() {
1324            Text('Scale down, start a new line, and then clip').fontSize(30).fontColor(0xFF000000)
1325          }.width('100%').height('100%').backgroundColor(Color.Pink)
1326        }
1327        .tabBar(SubTabBarStyle.of('Start [Scale down, start a new line, and then clip; Scale down, start a new line, and then clip] End')
1328          .labelStyle({
1329            overflow: TextOverflow.Clip,
1330            maxLines: 2,
1331            minFontSize: 15,
1332            maxFontSize: 15,
1333            heightAdaptivePolicy: TextHeightAdaptivePolicy.MIN_FONT_SIZE_FIRST,
1334            font: { size: 20 }
1335          }))
1336
1337        TabContent() {
1338          Column() {
1339            Text('Start a new line').fontSize(30).fontColor(0xFF000000)
1340          }
1341          .width('100%').height('100%').backgroundColor(Color.Pink)
1342        }.tabBar(SubTabBarStyle.of('Start [Start a new line; Start a new line; Start a new line; Start a new line; Start a new line] End')
1343          .labelStyle({
1344            overflow: TextOverflow.Clip,
1345            maxLines: 10,
1346            minFontSize: 10,
1347            heightAdaptivePolicy: TextHeightAdaptivePolicy.MAX_LINES_FIRST,
1348            font: { size: 20 }
1349          }))
1350      }
1351      .vertical(true).scrollable(true)
1352      .barMode(BarMode.Fixed)
1353      .barHeight(720)
1354      .barWidth(200).animationDuration(400)
1355      .onChange((index: number) => {
1356        console.info(index.toString())
1357      })
1358      .height('100%').width('100%')
1359    }
1360    .height('100%')
1361  }
1362}
1363```
1364
1365![tabContent4](figures/tabContent4.png)
1366
1367### Example 6: Setting Basic Attributes for Bottom Tabs
1368
1369This example demonstrates how to set basic attributes for bottom tabs using **padding**, **verticalAlign**, **layoutMode**, and **symmetricExtensible**.
1370
1371```ts
1372// xxx.ets
1373@Entry
1374@Component
1375struct TabContentExample6 {
1376  private controller: TabsController = new TabsController()
1377  @State text: string = "2"
1378  @State tabPadding: number = 0;
1379  @State symmetricExtensible: boolean = false;
1380  @State layoutMode: LayoutMode = LayoutMode.VERTICAL;
1381  @State verticalAlign: VerticalAlign = VerticalAlign.Center;
1382
1383  build() {
1384    Column() {
1385      Row() {
1386        Button("padding+10 " + this.tabPadding)
1387          .width('47%')
1388          .height(50)
1389          .margin({ top: 5 })
1390          .onClick((event?: ClickEvent) => {
1391            this.tabPadding += 10
1392          })
1393          .margin({ right: '6%', bottom: '12vp' })
1394        Button("padding-10 " + this.tabPadding)
1395          .width('47%')
1396          .height(50)
1397          .margin({ top: 5 })
1398          .onClick((event?: ClickEvent) => {
1399            this.tabPadding -= 10
1400          })
1401          .margin({ bottom: '12vp' })
1402      }
1403
1404      Row() {
1405        Button("Add Text")
1406          .width('47%')
1407          .height(50)
1408          .margin({ top: 5 })
1409          .onClick((event?: ClickEvent) => {
1410            this.text += 'Add Text'
1411          })
1412          .margin({ right: '6%', bottom: '12vp' })
1413        Button("Reset Text")
1414          .width('47%')
1415          .height(50)
1416          .margin({ top: 5 })
1417          .onClick((event?: ClickEvent) => {
1418            this.text = "2"
1419          })
1420          .margin({ bottom: '12vp' })
1421      }
1422
1423      Row() {
1424        Button("Set SymmetricExtensible to " + this.symmetricExtensible)
1425          .width('100%')
1426          .height(50)
1427          .margin({ top: 5 })
1428          .onClick((event?: ClickEvent) => {
1429            this.symmetricExtensible = !this.symmetricExtensible
1430          })
1431          .margin({ bottom: '12vp' })
1432      }
1433
1434      Row() {
1435        Button("Vertical Layout")
1436          .width('47%')
1437          .height(50)
1438          .margin({ top: 5 })
1439          .onClick((event?: ClickEvent) => {
1440            this.layoutMode = LayoutMode.VERTICAL;
1441          })
1442          .margin({ right: '6%', bottom: '12vp' })
1443        Button("Horizontal Layout")
1444          .width('47%')
1445          .height(50)
1446          .margin({ top: 5 })
1447          .onClick((event?: ClickEvent) => {
1448            this.layoutMode = LayoutMode.HORIZONTAL;
1449          })
1450          .margin({ bottom: '12vp' })
1451      }
1452
1453      Row() {
1454        Button("VerticalAlign.Top")
1455          .width('100%')
1456          .height(50)
1457          .margin({ top: 5 })
1458          .onClick((event?: ClickEvent) => {
1459            this.verticalAlign = VerticalAlign.Top;
1460          })
1461          .margin({ bottom: '12vp' })
1462      }
1463
1464      Row() {
1465        Button("VerticalAlign.Center")
1466          .width('100%')
1467          .height(50)
1468          .margin({ top: 5 })
1469          .onClick((event?: ClickEvent) => {
1470            this.verticalAlign = VerticalAlign.Center;
1471          })
1472          .margin({ bottom: '12vp' })
1473      }
1474
1475      Row() {
1476        Button("VerticalAlign.Bottom")
1477          .width('100%')
1478          .height(50)
1479          .margin({ top: 5 })
1480          .onClick((event?: ClickEvent) => {
1481            this.verticalAlign = VerticalAlign.Bottom;
1482          })
1483          .margin({ bottom: '12vp' })
1484      }
1485
1486
1487      Tabs({ barPosition: BarPosition.End, controller: this.controller }) {
1488        TabContent() {
1489          Column().width('100%').height('100%').backgroundColor(Color.Pink)
1490        }.tabBar(BottomTabBarStyle.of($r("sys.media.ohos_app_icon"), "1"))
1491
1492        TabContent() {
1493          Column().width('100%').height('100%').backgroundColor(Color.Green)
1494        }.tabBar(BottomTabBarStyle.of($r("sys.media.ohos_app_icon"), this.text)
1495          .padding(this.tabPadding)
1496          .verticalAlign(this.verticalAlign)
1497          .layoutMode(this.layoutMode)
1498          .symmetricExtensible(this.symmetricExtensible))
1499
1500        TabContent() {
1501          Column().width('100%').height('100%').backgroundColor(Color.Blue)
1502        }.tabBar(BottomTabBarStyle.of($r("sys.media.ohos_app_icon"), "3"))
1503      }
1504      .animationDuration(300)
1505      .height('60%')
1506      .backgroundColor(0xf1f3f5)
1507      .barMode(BarMode.Fixed)
1508    }
1509    .width('100%')
1510    .height(500)
1511    .margin({ top: 5 })
1512    .padding('24vp')
1513  }
1514}
1515```
1516
1517![tabContent4](figures/tabContent5.gif)
1518
1519### Example 7: Setting Text and Icon Colors for Subtabs and Bottom Tabs
1520
1521This example demonstrates how to change the text color of subtabs and bottom tabs using **unselectedColor** and **selectedColor** in **labelStyle** and how to change the icon color of bottom tabs using **unselectedColor** and **selectedColor** in **iconStyle**.
1522
1523```ts
1524// xxx.ets
1525@Entry
1526@Component
1527struct TabBarStyleExample {
1528  build() {
1529    Column({ space: 5 }) {
1530      Text("Subtab style")
1531      Column() {
1532        Tabs({ barPosition: BarPosition.Start }) {
1533          TabContent() {
1534            Column().width('100%').height('100%').backgroundColor(Color.Pink)
1535          }.tabBar(new SubTabBarStyle('Pink')
1536            .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Green }))
1537
1538          TabContent() {
1539            Column().width('100%').height('100%').backgroundColor(Color.Yellow)
1540          }.tabBar(new SubTabBarStyle('Yellow')
1541            .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Green }))
1542
1543          TabContent() {
1544            Column().width('100%').height('100%').backgroundColor(Color.Blue)
1545          }.tabBar(new SubTabBarStyle('Blue')
1546            .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Green }))
1547
1548          TabContent() {
1549            Column().width('100%').height('100%').backgroundColor(Color.Green)
1550          }.tabBar(new SubTabBarStyle('Green')
1551            .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Green })
1552          )
1553        }
1554        .vertical(false)
1555        .scrollable(true)
1556        .barMode(BarMode.Fixed)
1557        .onChange((index: number) => {
1558          console.info(index.toString())
1559        })
1560        .width('100%')
1561        .backgroundColor(0xF1F3F5)
1562      }.width('100%').height(200)
1563
1564      Text("Bottom tab style")
1565      Column() {
1566        Tabs({ barPosition: BarPosition.End }) {
1567          TabContent() {
1568            Column().width('100%').height('100%').backgroundColor(Color.Pink)
1569          }
1570          .tabBar(new BottomTabBarStyle('/common/public_icon_off.svg', 'pink')
1571            .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Green })
1572            .iconStyle({ unselectedColor: Color.Red, selectedColor: Color.Green })
1573          )
1574
1575          TabContent() {
1576            Column().width('100%').height('100%').backgroundColor(Color.Yellow)
1577          }.tabBar(new BottomTabBarStyle('/common/public_icon_off.svg', 'Yellow')
1578            .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Green })
1579            .iconStyle({ unselectedColor: Color.Red, selectedColor: Color.Green })
1580          )
1581
1582          TabContent() {
1583            Column().width('100%').height('100%').backgroundColor(Color.Blue)
1584          }.tabBar(new BottomTabBarStyle('/common/public_icon_off.svg', 'Blue')
1585            .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Green })
1586            .iconStyle({ unselectedColor: Color.Red, selectedColor: Color.Green })
1587          )
1588
1589          TabContent() {
1590            Column().width('100%').height('100%').backgroundColor(Color.Green)
1591          }.tabBar(new BottomTabBarStyle('/common/public_icon_off.svg', 'Green')
1592            .labelStyle({ unselectedColor: Color.Red, selectedColor: Color.Green })
1593            .iconStyle({ unselectedColor: Color.Red, selectedColor: Color.Green })
1594          )
1595        }
1596        .vertical(false)
1597        .scrollable(true)
1598        .barMode(BarMode.Fixed)
1599        .onChange((index: number) => {
1600          console.info(index.toString())
1601        })
1602        .width('100%')
1603        .backgroundColor(0xF1F3F5)
1604      }.width('100%').height(200)
1605    }
1606  }
1607}
1608```
1609
1610![tabContent](figures/tabContent6.gif)
1611
1612### Example 8 (customized subtabs)
1613
1614This example sets **SubTabBarStyle** through **ComponentContent**.
1615
1616```ts
1617// xxx.ets
1618import { ComponentContent, UIContext } from "@kit.ArkUI";
1619
1620class Params {
1621  text: string = ""
1622
1623  constructor(text: string) {
1624    this.text = text;
1625  }
1626}
1627
1628@Builder
1629function buildText(params: Params) {
1630  Column() {
1631    Text(params.text)
1632      .fontSize(20)
1633      .fontWeight(FontWeight.Bold)
1634      .margin(20)
1635  }
1636}
1637
1638@Entry
1639@Component
1640struct Index {
1641  @State message1: string = "tabBar1"
1642  @State message2: string = "tabBar2"
1643  context: UIContext = this.getUIContext()
1644  private count1 = 0;
1645  private count2 = 0;
1646  private controller: TabsController = new TabsController();
1647  tabBar1: ComponentContent<Params> = new ComponentContent<Params>(this.context, wrapBuilder<[Params]>(buildText), new Params(this.message1));
1648  tabBar2: ComponentContent<Params> = new ComponentContent<Params>(this.context, wrapBuilder<[Params]>(buildText), new Params(this.message2));
1649
1650  build() {
1651    Row() {
1652      Column() {
1653        Button("Update tabBar1").width('90%').margin(20)
1654          .onClick((event?: ClickEvent) => {
1655            this.count1 += 1;
1656            const message1 = "Update 1_" + this.count1.toString();
1657            this.tabBar1.update(new Params(message1));
1658          })
1659        Button("Update tabBar2").width('90%').margin(20)
1660          .onClick((event?: ClickEvent) => {
1661            this.count2 += 1;
1662            const message2 = "Update 2_" + this.count2.toString();
1663            this.tabBar2.update(new Params(message2));
1664          })
1665        Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
1666          TabContent() {
1667            Column().width('100%').height('100%').backgroundColor(Color.Pink).borderRadius('12vp')
1668          }.tabBar(new SubTabBarStyle(this.tabBar1))
1669          TabContent() {
1670            Column().width('100%').height('100%').backgroundColor(Color.Blue).borderRadius('12vp')
1671          }.tabBar(SubTabBarStyle.of(this.tabBar2))
1672        }
1673        .vertical(false)
1674        .barWidth(414)
1675        .barHeight(96)
1676        .width(414)
1677        .height(414)
1678        .backgroundColor('#F1F3F5')
1679        .margin({ top: 20 })
1680      }
1681      .width('100%')
1682      .height('100%')
1683    }
1684    .height('100%')
1685  }
1686}
1687```
1688
1689![tabContent7](figures/tabContent7.gif)
1690
1691### Example 9: Using Symbol Icons for Bottom Tabs
1692
1693This example shows how to use symbols as icons in **BottomTabBarStyle**.
1694
1695```ts
1696// xxx.ets
1697import { SymbolGlyphModifier } from '@kit.ArkUI';
1698
1699@Entry
1700@Component
1701struct Index {
1702  @State symbolModifier1: SymbolGlyphModifier = new SymbolGlyphModifier($r('sys.symbol.ohos_wifi'));
1703  @State symbolModifier2: SymbolGlyphModifier = new SymbolGlyphModifier($r('sys.symbol.ellipsis_bubble'));
1704  @State symbolModifier3: SymbolGlyphModifier = new SymbolGlyphModifier($r('sys.symbol.dot_video'));
1705  @State symbolModifier4: SymbolGlyphModifier = new SymbolGlyphModifier($r('sys.symbol.exposure'));
1706  build() {
1707    Column({space: 5}) {
1708      Text("Bottom tab style")
1709      Column(){
1710        Tabs({barPosition: BarPosition.End}) {
1711          TabContent() {
1712            Column().width('100%').height('100%').backgroundColor(Color.Pink)
1713          }.tabBar(new BottomTabBarStyle({
1714            normal: this.symbolModifier1,
1715          }, 'Pink'))
1716          .onWillShow(() => {
1717            console.info("Pink will show")
1718          })
1719          .onWillHide(() => {
1720            console.info("Pink will hide")
1721          })
1722
1723          TabContent() {
1724            Column().width('100%').height('100%').backgroundColor(Color.Orange)
1725          }.tabBar(new BottomTabBarStyle({
1726            normal: this.symbolModifier2,
1727          }, 'Orange'))
1728          .onWillShow(() => {
1729            console.info("Orange will show")
1730          })
1731          .onWillHide(() => {
1732            console.info("Orange will hide")
1733          })
1734
1735          TabContent() {
1736            Column().width('100%').height('100%').backgroundColor(Color.Blue)
1737          }.tabBar(new BottomTabBarStyle({
1738            normal: this.symbolModifier3,
1739          }, 'Blue'))
1740          .onWillShow(() => {
1741            console.info("Blue will show")
1742          })
1743          .onWillHide(() => {
1744            console.info("Blue will hide")
1745          })
1746
1747          TabContent() {
1748            Column().width('100%').height('100%').backgroundColor(Color.Green)
1749          }.tabBar(new BottomTabBarStyle({
1750            normal: this.symbolModifier4,
1751          }, 'Green'))
1752          .onWillShow(() => {
1753            console.info("Green will show")
1754          })
1755          .onWillHide(() => {
1756            console.info("Green will hide")
1757          })
1758        }
1759        .vertical(false)
1760        .scrollable(true)
1761        .barMode(BarMode.Fixed)
1762        .onChange((index:number)=>{
1763          console.info(index.toString())
1764        })
1765        .width('100%')
1766        .backgroundColor(0xF1F3F5)
1767      }.width('100%').height(200)
1768    }
1769  }
1770}
1771```
1772
1773![tabContent8](figures/tabBarSymbol.gif)
1774
1775### Example 10: Setting TabBar Using ComponentContent
1776
1777This example demonstrates how to use **ComponentContent** to encapsulate component content and set the **TabBar**. The **update** API of **ComponentContent** is used to update the **TabBar**.
1778
1779```ts
1780// xxx.ets
1781import { ComponentContent, UIContext } from "@kit.ArkUI";
1782
1783class Params {
1784  text: string = ""
1785  fontColor: string = ""
1786
1787  constructor(text: string, fontColor: string) {
1788    this.text = text;
1789    this.fontColor = fontColor;
1790  }
1791}
1792
1793@Builder
1794function buildText(params: Params) {
1795  Column() {
1796    Text(params.text)
1797      .fontColor(params.fontColor)
1798      .fontSize(20)
1799      .fontWeight(FontWeight.Bold)
1800      .margin(20)
1801  }
1802}
1803
1804@Entry
1805@Component
1806struct Index {
1807  @State currentIndex: number = 0
1808  @State message1: string = "tabBar1"
1809  @State message2: string = "tabBar2"
1810  unselectedFontColor: string = '#182431'
1811  selectedFontColor: string = '#007DFF'
1812  context: UIContext = this.getUIContext()
1813  private count1 = 0;
1814  private count2 = 0;
1815  private controller: TabsController = new TabsController();
1816
1817  getTabBar1() {
1818    this.tabBar1.update(new Params(this.message1,
1819      this.currentIndex === 0 ? this.selectedFontColor : this.unselectedFontColor));
1820    return this.tabBar1;
1821  }
1822
1823  getTabBar2() {
1824    this.tabBar2.update(new Params(this.message2,
1825      this.currentIndex === 1 ? this.selectedFontColor : this.unselectedFontColor));
1826    return this.tabBar2;
1827  }
1828
1829  tabBar1: ComponentContent<Params> =
1830    new ComponentContent<Params>(this.context, wrapBuilder<[Params]>(buildText),
1831      new Params(this.message1, this.selectedFontColor));
1832  tabBar2: ComponentContent<Params> =
1833    new ComponentContent<Params>(this.context, wrapBuilder<[Params]>(buildText),
1834      new Params(this.message2, this.unselectedFontColor));
1835
1836  build() {
1837    Row() {
1838      Column() {
1839        Button("Update tabBar1").width('90%').margin(20)
1840          .onClick((event?: ClickEvent) => {
1841            this.count1 += 1;
1842            this.message1 = "Update 1_" + this.count1.toString();
1843            this.tabBar1.update(new Params(this.message1, this.unselectedFontColor));
1844          })
1845        Button("Update tabBar2").width('90%').margin(20)
1846          .onClick((event?: ClickEvent) => {
1847            this.count2 += 1;
1848            this.message2 = "Update 2_" + this.count2.toString();
1849            this.tabBar2.update(new Params(this.message2, this.unselectedFontColor));
1850          })
1851        Tabs({ barPosition: BarPosition.Start, controller: this.controller }) {
1852          TabContent() {
1853            Column().width('100%').height('100%').backgroundColor(Color.Pink).borderRadius('12vp')
1854          }.tabBar(this.getTabBar1())
1855
1856          TabContent() {
1857            Column().width('100%').height('100%').backgroundColor(Color.Blue).borderRadius('12vp')
1858          }.tabBar(this.getTabBar2())
1859        }
1860        .vertical(false)
1861        .barWidth(414)
1862        .barHeight(96)
1863        .width(414)
1864        .height(414)
1865        .backgroundColor('#F1F3F5')
1866        .margin({ top: 20 })
1867        .onChange((index: number) => {
1868          this.currentIndex = index
1869        })
1870      }
1871      .width('100%')
1872      .height('100%')
1873    }
1874    .height('100%')
1875  }
1876}
1877```
1878
1879![tabContent9](figures/tabContent9.gif)
1880
1881### Example 11: Preloading Child Nodes Using ComponentContent
1882
1883This example demonstrates how to use **ComponentContent** to set the **TabBar** and preload child nodes using the **preloadItems** API of **TabsController**.
1884
1885```ts
1886// xxx.ets
1887import { BusinessError } from '@kit.BasicServicesKit';
1888import { ComponentContent } from '@kit.ArkUI';
1889
1890class Params {
1891  text: string = ""
1892  fontColor: string = ""
1893
1894  constructor(text: string, fontColor: string) {
1895    this.text = text;
1896    this.fontColor = fontColor;
1897  }
1898}
1899
1900@Component
1901struct imageCom {
1902  build() {
1903    Image($r("app.media.startIcon"))
1904      .alt($r('app.media.background'))
1905      .width(15)
1906      .height(15)
1907  }
1908}
1909
1910@Builder
1911function TabBuilder(params: Params) {
1912  Column({ space: 4 }) {
1913    imageCom()
1914
1915    Text(params.text)
1916      .fontSize(10)
1917      .fontColor(params.fontColor)
1918  }
1919}
1920
1921@Entry
1922@Component
1923struct TabsPreloadItems {
1924  @State currentIndex: number = 0
1925  private tabsController: TabsController = new TabsController()
1926  context: UIContext = this.getUIContext()
1927  unselectedFontColor: string = '#182431'
1928  selectedFontColor: string = '#007DFF'
1929
1930  getTabBar1() {
1931    this.tabBar1.update(new Params('green',
1932      this.currentIndex === 0 ? this.selectedFontColor : this.unselectedFontColor));
1933    return this.tabBar1;
1934  }
1935
1936  getTabBar2() {
1937    this.tabBar2.update(new Params('blue',
1938      this.currentIndex === 1 ? this.selectedFontColor : this.unselectedFontColor));
1939    return this.tabBar2;
1940  }
1941
1942  getTabBar3() {
1943    this.tabBar3.update(new Params('yellow',
1944      this.currentIndex === 2 ? this.selectedFontColor : this.unselectedFontColor));
1945    return this.tabBar3;
1946  }
1947
1948  getTabBar4() {
1949    this.tabBar4.update(new Params('pink',
1950      this.currentIndex === 3 ? this.selectedFontColor : this.unselectedFontColor));
1951    return this.tabBar4;
1952  }
1953
1954  tabBar1: ComponentContent<Params> =
1955    new ComponentContent<Params>(this.context, wrapBuilder<[Params]>(TabBuilder),
1956      new Params('green', this.selectedFontColor));
1957  tabBar2: ComponentContent<Params> =
1958    new ComponentContent<Params>(this.context, wrapBuilder<[Params]>(TabBuilder),
1959      new Params('blue', this.unselectedFontColor));
1960  tabBar3: ComponentContent<Params> =
1961    new ComponentContent<Params>(this.context, wrapBuilder<[Params]>(TabBuilder),
1962      new Params('yellow', this.unselectedFontColor));
1963  tabBar4: ComponentContent<Params> =
1964    new ComponentContent<Params>(this.context, wrapBuilder<[Params]>(TabBuilder),
1965      new Params('pink', this.unselectedFontColor));
1966
1967  build() {
1968    Column() {
1969      Tabs({ index: this.currentIndex, controller: this.tabsController }) {
1970        TabContent() {
1971          MyComponent({ color: '#00CB87' })
1972        }.tabBar(this.getTabBar1())
1973
1974        TabContent() {
1975          MyComponent({ color: '#007DFF' })
1976        }.tabBar(this.getTabBar2())
1977
1978        TabContent() {
1979          MyComponent({ color: '#FFBF00' })
1980        }.tabBar(this.getTabBar3())
1981
1982        TabContent() {
1983          MyComponent({ color: '#E67C92' })
1984        }.tabBar(this.getTabBar4())
1985      }
1986      .width(360)
1987      .height(296)
1988      .backgroundColor('#F1F3F5')
1989      .onChange((index: number) => {
1990        this.currentIndex = index
1991      })
1992
1993      Button('preload items: [1,2,3]')
1994        .margin(5)
1995        .onClick(() => {
1996          // Preload the 0th child node.
1997          this.tabsController.preloadItems([1, 2, 3])
1998            .then(() => {
1999              console.info('preloadItems success.')
2000            })
2001            .catch((error: BusinessError) => {
2002              console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message)
2003            })
2004        })
2005
2006      Button('preload items: [1]')
2007        .margin(5)
2008        .onClick(() => {
2009          // Preload the 0th child node.
2010          this.tabsController.preloadItems([1])
2011            .then(() => {
2012              console.info('preloadItems success.')
2013            })
2014            .catch((error: BusinessError) => {
2015              console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message)
2016            })
2017        })
2018      Button('preload items: [3]')
2019        .margin(5)
2020        .onClick(() => {
2021          // Preload the 0th child node.
2022          this.tabsController.preloadItems([3])
2023            .then(() => {
2024              console.info('preloadItems success.')
2025            })
2026            .catch((error: BusinessError) => {
2027              console.error('preloadItems failed, error code: ' + error.code + ', error message: ' + error.message)
2028            })
2029        })
2030    }
2031  }
2032}
2033
2034@Component
2035struct MyComponent {
2036  private color: string = ""
2037
2038  aboutToAppear(): void {
2039    console.info('aboutToAppear backgroundColor:' + this.color)
2040  }
2041
2042  aboutToDisappear(): void {
2043    console.info('aboutToDisappear backgroundColor:' + this.color)
2044  }
2045
2046  build() {
2047    Column()
2048      .width('100%')
2049      .height('100%')
2050      .backgroundColor(this.color)
2051  }
2052}
2053```
2054
2055![tabContent9](figures/tabContent10.gif)
2056