1e41f4b71Sopenharmony_ci# TextPicker 2e41f4b71Sopenharmony_ci 3e41f4b71Sopenharmony_ciThe **TextPicker** component allows users to scroll to select text. 4e41f4b71Sopenharmony_ci 5e41f4b71Sopenharmony_ci> **NOTE** 6e41f4b71Sopenharmony_ci> 7e41f4b71Sopenharmony_ci> This component is supported since API version 8. Updates will be marked with a superscript to indicate their earliest API version. 8e41f4b71Sopenharmony_ci 9e41f4b71Sopenharmony_ci 10e41f4b71Sopenharmony_ci## Child Components 11e41f4b71Sopenharmony_ci 12e41f4b71Sopenharmony_ciNot supported 13e41f4b71Sopenharmony_ci 14e41f4b71Sopenharmony_ci 15e41f4b71Sopenharmony_ci## APIs 16e41f4b71Sopenharmony_ci 17e41f4b71Sopenharmony_ciTextPicker(options?: TextPickerOptions) 18e41f4b71Sopenharmony_ci 19e41f4b71Sopenharmony_ciCreates a text picker based on the selection range specified by **range**. 20e41f4b71Sopenharmony_ci 21e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 22e41f4b71Sopenharmony_ci 23e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 24e41f4b71Sopenharmony_ci 25e41f4b71Sopenharmony_ci**Parameters** 26e41f4b71Sopenharmony_ci 27e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 28e41f4b71Sopenharmony_ci| ------- | ----------------------------------------------- | ---- | ---------------------- | 29e41f4b71Sopenharmony_ci| options | [TextPickerOptions](#textpickeroptions) | No | Parameters of the text picker.| 30e41f4b71Sopenharmony_ci 31e41f4b71Sopenharmony_ci## TextPickerOptions 32e41f4b71Sopenharmony_ci 33e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 34e41f4b71Sopenharmony_ci 35e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 36e41f4b71Sopenharmony_ci 37e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description| 38e41f4b71Sopenharmony_ci| -------- | -------- | -------- | -------- | 39e41f4b71Sopenharmony_ci| range | string[] \| string[] []<sup>10+</sup> \| [Resource](ts-types.md#resource) \|<br>[TextPickerRangeContent](#textpickerrangecontent10)[]<sup>10+</sup> \| [TextCascadePickerRangeContent](#textcascadepickerrangecontent10)[]<sup>10+</sup> | Yes| Data selection range of the picker. This parameter cannot be set to an empty array. If set to an empty array, it will not be displayed. If it is dynamically changed to an empty array, the current value remains displayed.<br>**NOTE**<br>For a single-column picker, use a value of the string[], Resource, or TextPickerRangeContent[] type.<br>For a multi-column picker, use a value of the string[] type.<br>For a multi-column linked picker, use a value of the TextCascadePickerRangeContent[] type.<br>The Resource type supports only [strarray.json](../../../quick-start/resource-categories-and-access.md#resource-group-directories).<br>The type and number of columns in the range cannot be dynamically modified.| 40e41f4b71Sopenharmony_ci| selected | number \| number[]<sup>10+</sup> | No| Index of the default item in the range.<br>Default value: **0**<br>**NOTE**<br>For a single-column picker, use a value of the number type.<br>For a multi-column (linked) picker, use a value of the number[] type.<br>Since API version 10, this attribute supports two-way binding through [$$](../../../quick-start/arkts-two-way-sync.md).| 41e41f4b71Sopenharmony_ci| value | string \| string[]<sup>10+</sup> | No| Value of the default item in the range. The priority of this parameter is lower than that of **selected**.<br>Default value: value of the first item<br>**NOTE**<br>This parameter works only when the picker contains text only. <br>For a single-column picker, use a value of the string type.<br>For a multi-column (linked) picker, use a value of the string[] type.<br>Since API version 10, this attribute supports two-way binding through [$$](../../../quick-start/arkts-two-way-sync.md).| 42e41f4b71Sopenharmony_ci 43e41f4b71Sopenharmony_ci## TextPickerRangeContent<sup>10+</sup> 44e41f4b71Sopenharmony_ci 45e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 46e41f4b71Sopenharmony_ci 47e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 48e41f4b71Sopenharmony_ci 49e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 50e41f4b71Sopenharmony_ci| ------ | -------------------------------------------------------- | ---- | ---------- | 51e41f4b71Sopenharmony_ci| icon | string \| [Resource](ts-types.md#resource) | Yes | Image resource.| 52e41f4b71Sopenharmony_ci| text | string \| [Resource](ts-types.md#resource) | No | Text information.| 53e41f4b71Sopenharmony_ci 54e41f4b71Sopenharmony_ci## TextCascadePickerRangeContent<sup>10+</sup> 55e41f4b71Sopenharmony_ci 56e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 57e41f4b71Sopenharmony_ci 58e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 59e41f4b71Sopenharmony_ci 60e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 61e41f4b71Sopenharmony_ci| ------ | -------------------------------------------------------- | ---- | ---------- | 62e41f4b71Sopenharmony_ci| text | string \| [Resource](ts-types.md#resource) | Yes | Text information.| 63e41f4b71Sopenharmony_ci| children | [TextCascadePickerRangeContent](#textcascadepickerrangecontent10)[] | No | Linkage data.| 64e41f4b71Sopenharmony_ci## DividerOptions<sup>12+</sup> 65e41f4b71Sopenharmony_ci 66e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 67e41f4b71Sopenharmony_ci 68e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 69e41f4b71Sopenharmony_ci 70e41f4b71Sopenharmony_ci| Name | Type | Mandatory| Description | 71e41f4b71Sopenharmony_ci| ----------- | ------------- | ---- | -------------------------------------------------------------- | 72e41f4b71Sopenharmony_ci| strokeWidth | [Dimension](ts-types.md#dimension10) | No | Stroke width of the divider. The unit is vp by default. You can also specify it as px. The percentage type is not supported.| 73e41f4b71Sopenharmony_ci| startMargin | [Dimension](ts-types.md#dimension10) | No | Distance between the divider and the start edge of the picker. The unit is vp by default. You can also specify it as px. The percentage type is not supported.| 74e41f4b71Sopenharmony_ci| endMargin | [Dimension](ts-types.md#dimension10) | No | Distance between the divider and the end edge of the picker. The unit is vp by default. You can also specify it as px. The percentage type is not supported.| 75e41f4b71Sopenharmony_ci| color | [ResourceColor](ts-types.md#resourcecolor) | No | Color of the divider. 76e41f4b71Sopenharmony_ci 77e41f4b71Sopenharmony_ci## Attributes 78e41f4b71Sopenharmony_ci 79e41f4b71Sopenharmony_ciIn addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported. 80e41f4b71Sopenharmony_ci 81e41f4b71Sopenharmony_ci### defaultPickerItemHeight 82e41f4b71Sopenharmony_ci 83e41f4b71Sopenharmony_cidefaultPickerItemHeight(value: number | string) 84e41f4b71Sopenharmony_ci 85e41f4b71Sopenharmony_ciSets the height of each item in the picker. 86e41f4b71Sopenharmony_ci 87e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 88e41f4b71Sopenharmony_ci 89e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 90e41f4b71Sopenharmony_ci 91e41f4b71Sopenharmony_ci**Parameters** 92e41f4b71Sopenharmony_ci 93e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 94e41f4b71Sopenharmony_ci| ------ | -------------------------- | ---- | ---------------------- | 95e41f4b71Sopenharmony_ci| value | number \| string | Yes | Height of each item in the picker.| 96e41f4b71Sopenharmony_ci 97e41f4b71Sopenharmony_ci### disappearTextStyle<sup>10+</sup> 98e41f4b71Sopenharmony_ci 99e41f4b71Sopenharmony_cidisappearTextStyle(value: PickerTextStyle) 100e41f4b71Sopenharmony_ci 101e41f4b71Sopenharmony_ciSets the font color, font size, and font weight for the top and bottom items. 102e41f4b71Sopenharmony_ci 103e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 104e41f4b71Sopenharmony_ci 105e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 106e41f4b71Sopenharmony_ci 107e41f4b71Sopenharmony_ci**Parameters** 108e41f4b71Sopenharmony_ci 109e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 110e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 111e41f4b71Sopenharmony_ci| value | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | Yes | Font color, font size, and font weight of the top and bottom items.<br>Default value:<br>{<br>color: '#ff182431',<br>font: {<br>size: '14fp', <br>weight: FontWeight.Regular<br>}<br>} | 112e41f4b71Sopenharmony_ci 113e41f4b71Sopenharmony_ci### textStyle<sup>10+</sup> 114e41f4b71Sopenharmony_ci 115e41f4b71Sopenharmony_citextStyle(value: PickerTextStyle) 116e41f4b71Sopenharmony_ci 117e41f4b71Sopenharmony_ciSets the font color, font size, and font weight for all items except the top, bottom, and selected items. 118e41f4b71Sopenharmony_ci 119e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 120e41f4b71Sopenharmony_ci 121e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 122e41f4b71Sopenharmony_ci 123e41f4b71Sopenharmony_ci**Parameters** 124e41f4b71Sopenharmony_ci 125e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 126e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 127e41f4b71Sopenharmony_ci| value | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | Yes | Font color, font size, and font weight of all items except the top, bottom, and selected items.<br>Default value:<br>{<br>color: '#ff182431',<br>font: {<br>size: '16fp', <br>weight: FontWeight.Regular<br>}<br>} | 128e41f4b71Sopenharmony_ci 129e41f4b71Sopenharmony_ci### selectedTextStyle<sup>10+</sup> 130e41f4b71Sopenharmony_ci 131e41f4b71Sopenharmony_ciselectedTextStyle(value: PickerTextStyle) 132e41f4b71Sopenharmony_ci 133e41f4b71Sopenharmony_ciSets the font color, font size, and font weight for the selected item. 134e41f4b71Sopenharmony_ci 135e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 136e41f4b71Sopenharmony_ci 137e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 138e41f4b71Sopenharmony_ci 139e41f4b71Sopenharmony_ci**Parameters** 140e41f4b71Sopenharmony_ci 141e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 142e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | 143e41f4b71Sopenharmony_ci| value | [PickerTextStyle](ts-basic-components-datepicker.md#pickertextstyle10) | Yes | Font color, font size, and font weight of the selected item.<br>Default value:<br>{<br>color: '#ff007dff',<br>font: {<br>size: '20vp', <br>weight: FontWeight.Medium<br>}<br>} | 144e41f4b71Sopenharmony_ci 145e41f4b71Sopenharmony_ci### selectedIndex<sup>10+</sup> 146e41f4b71Sopenharmony_ci 147e41f4b71Sopenharmony_ciselectedIndex(value: number | number[]) 148e41f4b71Sopenharmony_ci 149e41f4b71Sopenharmony_ciSets the index of the default selected item in the array. Its priority is higher than that of the selected value in **options**. For a single-column picker, use a value of the number type. For a multi-column (linked) picker, use a value of the number[] type. 150e41f4b71Sopenharmony_ci 151e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 152e41f4b71Sopenharmony_ci 153e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 154e41f4b71Sopenharmony_ci 155e41f4b71Sopenharmony_ci**Parameters** 156e41f4b71Sopenharmony_ci 157e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 158e41f4b71Sopenharmony_ci| ------ | ---------------------------- | ---- | ---------------------------- | 159e41f4b71Sopenharmony_ci| value | number \| number[] | Yes | Index of the default selected item in the array.<br>Default value: **0**<br>| 160e41f4b71Sopenharmony_ci 161e41f4b71Sopenharmony_ci### canLoop<sup>10+</sup> 162e41f4b71Sopenharmony_ci 163e41f4b71Sopenharmony_cicanLoop(value: boolean) 164e41f4b71Sopenharmony_ci 165e41f4b71Sopenharmony_ciSets whether scrolling is loopable. 166e41f4b71Sopenharmony_ci 167e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 168e41f4b71Sopenharmony_ci 169e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 170e41f4b71Sopenharmony_ci 171e41f4b71Sopenharmony_ci**Parameters** 172e41f4b71Sopenharmony_ci 173e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 174e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------------------------------ | 175e41f4b71Sopenharmony_ci| value | boolean | Yes | Whether scrolling is loopable.<br>**true**: loopable<br>**false**: not loopable<br>Default value: **true**| 176e41f4b71Sopenharmony_ci 177e41f4b71Sopenharmony_ci### divider<sup>12+</sup> 178e41f4b71Sopenharmony_ci 179e41f4b71Sopenharmony_cidivider(value: DividerOptions | null) 180e41f4b71Sopenharmony_ci 181e41f4b71Sopenharmony_ciSets the divider style. If this attribute is not set, the divider is displayed based on the default value. 182e41f4b71Sopenharmony_ci 183e41f4b71Sopenharmony_ciIf the sum of **startMargin** and **endMargin** exceeds the component width, both **startMargin** and **endMargin** will be set to **0**. 184e41f4b71Sopenharmony_ci 185e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 186e41f4b71Sopenharmony_ci 187e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 188e41f4b71Sopenharmony_ci 189e41f4b71Sopenharmony_ci**Parameters** 190e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 191e41f4b71Sopenharmony_ci| ------ | ------- | ---- | --------------------------------------------------------------------- | 192e41f4b71Sopenharmony_ci| value | [DividerOptions](#divideroptions12) \| null | Yes | Divider options.<br>1. If **DividerOptions** is set, the divider is displayed in the configured style.<br>Default value:<br>{<br>strokeWidth: '2px', <br>startMargin: 0, <br>endMargin: 0, <br>color: '#33000000'<br>}<br>2. If this parameter is set to **null**, the divider is not displayed.| 193e41f4b71Sopenharmony_ci 194e41f4b71Sopenharmony_ci### gradientHeight<sup>12+</sup> 195e41f4b71Sopenharmony_ci 196e41f4b71Sopenharmony_cigradientHeight(value: Dimension) 197e41f4b71Sopenharmony_ci 198e41f4b71Sopenharmony_ciSets the height for the fade-out effect. If this attribute is not set, the default fade-out effect will be displayed. 199e41f4b71Sopenharmony_ci 200e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12. 201e41f4b71Sopenharmony_ci 202e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 203e41f4b71Sopenharmony_ci 204e41f4b71Sopenharmony_ci**Parameters** 205e41f4b71Sopenharmony_ci 206e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 207e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------------------------------ | 208e41f4b71Sopenharmony_ci| value | [Dimension](ts-types.md#dimension10) | Yes | Height of the gradient effect at the top and bottom edges of the content area. It can be set in percentage, with 100% (the maximum value) being half the height of the picker. Setting it to **0** will result in no gradient effect, while negative numbers or other invalid values will display the default gradient effect. Default value: **36vp**| 209e41f4b71Sopenharmony_ci 210e41f4b71Sopenharmony_ci> **NOTE** 211e41f4b71Sopenharmony_ci> 212e41f4b71Sopenharmony_ci> Avoid changing the attribute data during the animation process of this component. 213e41f4b71Sopenharmony_ci 214e41f4b71Sopenharmony_ci## Events 215e41f4b71Sopenharmony_ci 216e41f4b71Sopenharmony_ciIn addition to the [universal events](ts-universal-events-click.md), the following events are supported. 217e41f4b71Sopenharmony_ci 218e41f4b71Sopenharmony_ci### onAccept<sup>(deprecated) </sup> 219e41f4b71Sopenharmony_ci 220e41f4b71Sopenharmony_cionAccept(callback: (value: string, index: number) => void) 221e41f4b71Sopenharmony_ci 222e41f4b71Sopenharmony_ciTriggered when the OK button in the dialog box is clicked. This event can be triggered only in the [text picker dialog box](ts-methods-textpicker-dialog.md). 223e41f4b71Sopenharmony_ci 224e41f4b71Sopenharmony_ciThis API is deprecated since API version 10. 225e41f4b71Sopenharmony_ci 226e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 227e41f4b71Sopenharmony_ci 228e41f4b71Sopenharmony_ci**Parameters** 229e41f4b71Sopenharmony_ci 230e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 231e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------------- | 232e41f4b71Sopenharmony_ci| value | string | Yes | Text of the selected item. | 233e41f4b71Sopenharmony_ci| index | number | Yes | Index of the selected item.| 234e41f4b71Sopenharmony_ci 235e41f4b71Sopenharmony_ci### onCancel<sup>(deprecated) </sup> 236e41f4b71Sopenharmony_ci 237e41f4b71Sopenharmony_cionCancel(callback: () => void) 238e41f4b71Sopenharmony_ci 239e41f4b71Sopenharmony_ciTriggered when the Cancel button in the dialog box is clicked. This event can be triggered only in the [text picker dialog box](ts-methods-textpicker-dialog.md). 240e41f4b71Sopenharmony_ci 241e41f4b71Sopenharmony_ciThis API is deprecated since API version 10. 242e41f4b71Sopenharmony_ci 243e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 244e41f4b71Sopenharmony_ci 245e41f4b71Sopenharmony_ci### onChange 246e41f4b71Sopenharmony_ci 247e41f4b71Sopenharmony_cionChange(callback: (value: string \| string[], index: number \| number[]) => void) 248e41f4b71Sopenharmony_ci 249e41f4b71Sopenharmony_ciTriggered when an item in the picker is selected. When the picker contains text only or both text and imagery, **value** indicates the text of the selected item. When the picker contains imagery only, **value** is empty. 250e41f4b71Sopenharmony_ci 251e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11. 252e41f4b71Sopenharmony_ci 253e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full 254e41f4b71Sopenharmony_ci 255e41f4b71Sopenharmony_ci**Parameters** 256e41f4b71Sopenharmony_ci 257e41f4b71Sopenharmony_ci| Name| Type | Mandatory| Description | 258e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ------------------------------------------------- | 259e41f4b71Sopenharmony_ci| value | string \| string[]<sup>10+</sup> | Yes | Text of the selected item. For a multi-column picker, **value** is of the array type. | 260e41f4b71Sopenharmony_ci| index | number \| number[]<sup>10+</sup> | Yes | Index of the selected item. For a multi-column picker, **index** is of the array type.| 261e41f4b71Sopenharmony_ci 262e41f4b71Sopenharmony_ci 263e41f4b71Sopenharmony_ci## Example 264e41f4b71Sopenharmony_ci 265e41f4b71Sopenharmony_ci```ts 266e41f4b71Sopenharmony_ci// xxx.ets 267e41f4b71Sopenharmony_ciclass bottom { 268e41f4b71Sopenharmony_ci bottom:number = 50 269e41f4b71Sopenharmony_ci} 270e41f4b71Sopenharmony_cilet bott:bottom = new bottom() 271e41f4b71Sopenharmony_ci@Entry 272e41f4b71Sopenharmony_ci@Component 273e41f4b71Sopenharmony_cistruct TextPickerExample { 274e41f4b71Sopenharmony_ci private select: number = 1 275e41f4b71Sopenharmony_ci private apfruits: string[] = ['apple1', 'apple2', 'apple3', 'apple4'] 276e41f4b71Sopenharmony_ci private orfruits: string[] = ['orange1', 'orange2', 'orange3', 'orange4'] 277e41f4b71Sopenharmony_ci private pefruits: string[] = ['peach1', 'peach2', 'peach3', 'peach4'] 278e41f4b71Sopenharmony_ci private multi: string[][] = [this.apfruits, this.orfruits, this.pefruits] 279e41f4b71Sopenharmony_ci private cascade: TextCascadePickerRangeContent[] = [ 280e41f4b71Sopenharmony_ci { 281e41f4b71Sopenharmony_ci text: 'Category 1', 282e41f4b71Sopenharmony_ci children: [{ text: 'Subcategory 1', children: [{ text: 'Subcategory 2' }, { text: 'Subcategory 3' }, { text: 'Subcategory 4' }] }, 283e41f4b71Sopenharmony_ci { text: 'Item 1', children: [{ text: ''Item 2' }, { text: ''Item 3' }, { text: ''Item 4' }] }] 284e41f4b71Sopenharmony_ci }, 285e41f4b71Sopenharmony_ci { 286e41f4b71Sopenharmony_ci text: 'Category 2', 287e41f4b71Sopenharmony_ci children: [{ text: 'Subcategory 1', children: [{ text: 'Subcategory 2' }, { text: 'Subcategory 3' }, { text: 'Subcategory 4' }] }, 288e41f4b71Sopenharmony_ci { text: 'Item 1', children: [{ text: ''Item 2' }, { text: ''Item 3' }, { text: ''Item 4' }] }] 289e41f4b71Sopenharmony_ci }, 290e41f4b71Sopenharmony_ci { 291e41f4b71Sopenharmony_ci text: 'Category 3', 292e41f4b71Sopenharmony_ci children: [{ text: 'Subcategory 1', children: [{ text: 'Subcategory 2' }, { text: 'Subcategory 3' }, { text: 'Subcategory 4' }] }, 293e41f4b71Sopenharmony_ci { text: 'Item 1', children: [{ text: ''Item 2' }, { text: ''Item 3' }, { text: ''Item 4' }] }] 294e41f4b71Sopenharmony_ci } 295e41f4b71Sopenharmony_ci ] 296e41f4b71Sopenharmony_ci 297e41f4b71Sopenharmony_ci build() { 298e41f4b71Sopenharmony_ci Column() { 299e41f4b71Sopenharmony_ci 300e41f4b71Sopenharmony_ci TextPicker({ range: this.apfruits, selected: this.select }) 301e41f4b71Sopenharmony_ci .onChange((value: string | string[], index: number | number[]) => { 302e41f4b71Sopenharmony_ci console.info('Picker item changed, value: ' + value + ', index: ' + index) 303e41f4b71Sopenharmony_ci }).margin(bott) 304e41f4b71Sopenharmony_ci 305e41f4b71Sopenharmony_ci TextPicker({ range: this.multi }) 306e41f4b71Sopenharmony_ci .onChange((value: string | string[], index: number | number[]) => { 307e41f4b71Sopenharmony_ci console.info('TextPicker multi-column: onChange' + JSON.stringify(value) + ',' + 'index:' + JSON.stringify(index)) 308e41f4b71Sopenharmony_ci }).margin(bott) 309e41f4b71Sopenharmony_ci 310e41f4b71Sopenharmony_ci TextPicker({ range: this.cascade }) 311e41f4b71Sopenharmony_ci .onChange((value: string | string[], index: number | number[]) => { 312e41f4b71Sopenharmony_ci console.info('TextPicker multi-column linkage: onChange' + JSON.stringify(value) + ',' + 'index:' + JSON.stringify(index)) 313e41f4b71Sopenharmony_ci }) 314e41f4b71Sopenharmony_ci } 315e41f4b71Sopenharmony_ci } 316e41f4b71Sopenharmony_ci} 317e41f4b71Sopenharmony_ci``` 318e41f4b71Sopenharmony_ci 319e41f4b71Sopenharmony_ci 320e41f4b71Sopenharmony_ci 321e41f4b71Sopenharmony_ci```ts 322e41f4b71Sopenharmony_ci// xxx.ets 323e41f4b71Sopenharmony_ci@Entry 324e41f4b71Sopenharmony_ci@Component 325e41f4b71Sopenharmony_cistruct TextPickerExample { 326e41f4b71Sopenharmony_ci private select: number = 1 327e41f4b71Sopenharmony_ci private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4'] 328e41f4b71Sopenharmony_ci 329e41f4b71Sopenharmony_ci build() { 330e41f4b71Sopenharmony_ci Column() { 331e41f4b71Sopenharmony_ci TextPicker({ range: this.fruits, selected: this.select }) 332e41f4b71Sopenharmony_ci .onChange((value: string | string[], index: number | number[]) => { 333e41f4b71Sopenharmony_ci console.info('Picker item changed, value: ' + value + ', index: ' + index) 334e41f4b71Sopenharmony_ci }) 335e41f4b71Sopenharmony_ci .disappearTextStyle({color: Color.Red, font: {size: 15, weight: FontWeight.Lighter}}) 336e41f4b71Sopenharmony_ci .textStyle({color: Color.Black, font: {size: 20, weight: FontWeight.Normal}}) 337e41f4b71Sopenharmony_ci .selectedTextStyle({color: Color.Blue, font: {size: 30, weight: FontWeight.Bolder}}) 338e41f4b71Sopenharmony_ci }.width('100%').height('100%') 339e41f4b71Sopenharmony_ci } 340e41f4b71Sopenharmony_ci} 341e41f4b71Sopenharmony_ci``` 342e41f4b71Sopenharmony_ci 343e41f4b71Sopenharmony_ci 344e41f4b71Sopenharmony_ci 345e41f4b71Sopenharmony_ci```ts 346e41f4b71Sopenharmony_ci// xxx.ets 347e41f4b71Sopenharmony_ci@Entry 348e41f4b71Sopenharmony_ci@Component 349e41f4b71Sopenharmony_cistruct TextPickerExample { 350e41f4b71Sopenharmony_ci private select: number = 1 351e41f4b71Sopenharmony_ci private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4'] 352e41f4b71Sopenharmony_ci 353e41f4b71Sopenharmony_ci build() { 354e41f4b71Sopenharmony_ci Column() { 355e41f4b71Sopenharmony_ci TextPicker({ range: this.fruits, selected: this.select }) 356e41f4b71Sopenharmony_ci .onChange((value: string | string[], index: number | number[]) => { 357e41f4b71Sopenharmony_ci console.info('Picker item changed, value: ' + value + ', index: ' + index) 358e41f4b71Sopenharmony_ci }) 359e41f4b71Sopenharmony_ci .disappearTextStyle({color: Color.Red, font: {size: 15, weight: FontWeight.Lighter}}) 360e41f4b71Sopenharmony_ci .textStyle({color: Color.Black, font: {size: 20, weight: FontWeight.Normal}}) 361e41f4b71Sopenharmony_ci .selectedTextStyle({color: Color.Blue, font: {size: 30, weight: FontWeight.Bolder}}) 362e41f4b71Sopenharmony_ci .divider(null) 363e41f4b71Sopenharmony_ci }.width('100%').height('100%') 364e41f4b71Sopenharmony_ci } 365e41f4b71Sopenharmony_ci} 366e41f4b71Sopenharmony_ci``` 367e41f4b71Sopenharmony_ci 368e41f4b71Sopenharmony_ci 369e41f4b71Sopenharmony_ci```ts 370e41f4b71Sopenharmony_ci// xxx.ets 371e41f4b71Sopenharmony_ci@Entry 372e41f4b71Sopenharmony_ci@Component 373e41f4b71Sopenharmony_cistruct TextPickerExample { 374e41f4b71Sopenharmony_ci private select: number = 1 375e41f4b71Sopenharmony_ci private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4'] 376e41f4b71Sopenharmony_ci 377e41f4b71Sopenharmony_ci build() { 378e41f4b71Sopenharmony_ci Column() { 379e41f4b71Sopenharmony_ci TextPicker({ range: this.fruits, selected: this.select }) 380e41f4b71Sopenharmony_ci .onChange((value: string | string[], index: number | number[]) => { 381e41f4b71Sopenharmony_ci console.info('Picker item changed, value: ' + value + ', index: ' + index) 382e41f4b71Sopenharmony_ci }) 383e41f4b71Sopenharmony_ci .disappearTextStyle({color: Color.Red, font: {size: 15, weight: FontWeight.Lighter}}) 384e41f4b71Sopenharmony_ci .textStyle({color: Color.Black, font: {size: 20, weight: FontWeight.Normal}}) 385e41f4b71Sopenharmony_ci .selectedTextStyle({color: Color.Blue, font: {size: 30, weight: FontWeight.Bolder}}) 386e41f4b71Sopenharmony_ci .divider({ 387e41f4b71Sopenharmony_ci strokeWidth: 10, 388e41f4b71Sopenharmony_ci color: Color.Red, 389e41f4b71Sopenharmony_ci startMargin: 10, 390e41f4b71Sopenharmony_ci endMargin: 20 391e41f4b71Sopenharmony_ci } as DividerOptions) 392e41f4b71Sopenharmony_ci }.width('100%').height('100%') 393e41f4b71Sopenharmony_ci } 394e41f4b71Sopenharmony_ci} 395e41f4b71Sopenharmony_ci``` 396e41f4b71Sopenharmony_ci 397e41f4b71Sopenharmony_ci```ts 398e41f4b71Sopenharmony_ci// xxx.ets. This example customizes the height the gradient effect for the text picker through gradientHeight(). 399e41f4b71Sopenharmony_ci@Entry 400e41f4b71Sopenharmony_ci@Component 401e41f4b71Sopenharmony_cistruct TextPickerExample { 402e41f4b71Sopenharmony_ci private select: number = 1 403e41f4b71Sopenharmony_ci private fruits: string[] = ['apple1', 'orange2', 'peach3', 'grape4'] 404e41f4b71Sopenharmony_ci 405e41f4b71Sopenharmony_ci build() { 406e41f4b71Sopenharmony_ci Column() { 407e41f4b71Sopenharmony_ci TextPicker({ range: this.fruits, selected: this.select }) 408e41f4b71Sopenharmony_ci .onChange((value: string | string[], index: number | number[]) => { 409e41f4b71Sopenharmony_ci console.info('Picker item changed, value: ' + value + ', index: ' + index) 410e41f4b71Sopenharmony_ci }) 411e41f4b71Sopenharmony_ci .disappearTextStyle({color: Color.Red, font: {size: 15, weight: FontWeight.Lighter}}) 412e41f4b71Sopenharmony_ci .textStyle({color: Color.Black, font: {size: 20, weight: FontWeight.Normal}}) 413e41f4b71Sopenharmony_ci .selectedTextStyle({color: Color.Blue, font: {size: 30, weight: FontWeight.Bolder}}) 414e41f4b71Sopenharmony_ci .gradientHeight(100) 415e41f4b71Sopenharmony_ci }.width('100%').height('100%') 416e41f4b71Sopenharmony_ci } 417e41f4b71Sopenharmony_ci} 418e41f4b71Sopenharmony_ci``` 419e41f4b71Sopenharmony_ci 420e41f4b71Sopenharmony_ci 421