1e41f4b71Sopenharmony_ci#  Search
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ciThe **Search** component provides an area for users to enter search queries.
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## Child Components
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ciNot supported
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ci## APIs
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ciSearch(options?: { value?: string, placeholder?: ResourceStr, icon?: string, controller?: SearchController })
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ci**Parameters**
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci| Name     | Type        | Mandatory| Description       |
24e41f4b71Sopenharmony_ci| ----------- | ------------- | ---- | ------------- |
25e41f4b71Sopenharmony_ci| value       | string                                               | No  | Sets the text input in the search text box.<br>Since API version 10, this parameter supports two-way binding through [$$](../../../quick-start/arkts-two-way-sync.md).|
26e41f4b71Sopenharmony_ci| placeholder | [ResourceStr](ts-types.md#resourcestr)<sup>10+</sup> | No  | Text displayed when there is no input.                                    |
27e41f4b71Sopenharmony_ci| icon        | string                                               | No  | Path to the search icon. By default, the system search icon is used.<br>**NOTE**<br>The icon data source can be a local or online image.<br>- The supported formats include PNG, JPG, BMP, SVG, GIF, pixelmap, and HEIF.<br>- The Base64 string is supported in the following format: data:image/[png\|jpeg\|bmp\|webp\|heif];base64,[base64 data], where *[base64 data]* is a Base64 string.<br>If this attribute and the **searchIcon** attribute are both set, the **searchIcon** attribute takes precedence.|
28e41f4b71Sopenharmony_ci| controller  | [SearchController](#searchcontroller) | No  | Controller of the **Search** component.                                      |
29e41f4b71Sopenharmony_ci
30e41f4b71Sopenharmony_ci## Attributes
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ciIn addition to the [universal attributes](ts-universal-attributes-size.md), the following attributes are supported.
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ci### searchButton
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_cisearchButton(value: string, option?: SearchButtonOptions)
37e41f4b71Sopenharmony_ci
38e41f4b71Sopenharmony_ciSets the text on the search button located next to the search text box.
39e41f4b71Sopenharmony_ci
40e41f4b71Sopenharmony_ciClicking the search button triggers both **onSubmit** and **onClick** callbacks.
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
45e41f4b71Sopenharmony_ci
46e41f4b71Sopenharmony_ci**Parameters**
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci| Name| Type                                                 | Mandatory| Description                        |
49e41f4b71Sopenharmony_ci| ------ | ----------------------------------------------------- | ---- | ---------------------------- |
50e41f4b71Sopenharmony_ci| value  | string                                                | Yes  | Text on the search button located next to the search text box.|
51e41f4b71Sopenharmony_ci| option | [SearchButtonOptions](#searchbuttonoptions10) | No  | Font of the search text box.<br>Default value:<br>{<br>fontSize: '16fp',<br>fontColor: '#ff3f97e9'<br>}         |
52e41f4b71Sopenharmony_ci
53e41f4b71Sopenharmony_ci### placeholderColor
54e41f4b71Sopenharmony_ci
55e41f4b71Sopenharmony_ciplaceholderColor(value: ResourceColor)
56e41f4b71Sopenharmony_ci
57e41f4b71Sopenharmony_ciSets the placeholder text color.
58e41f4b71Sopenharmony_ci
59e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
60e41f4b71Sopenharmony_ci
61e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
62e41f4b71Sopenharmony_ci
63e41f4b71Sopenharmony_ci**Parameters**
64e41f4b71Sopenharmony_ci
65e41f4b71Sopenharmony_ci| Name| Type                                      | Mandatory| Description                                            |
66e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ------------------------------------------------ |
67e41f4b71Sopenharmony_ci| value  | [ResourceColor](ts-types.md#resourcecolor) | Yes  | Placeholder text color.<br>Default value: **'#99182431'**|
68e41f4b71Sopenharmony_ci
69e41f4b71Sopenharmony_ci### placeholderFont
70e41f4b71Sopenharmony_ci
71e41f4b71Sopenharmony_ciplaceholderFont(value?: Font)
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ciSets the placeholder text style, including the font size, font width, font family, and font style. Currently, only the default font family is supported.
74e41f4b71Sopenharmony_ci
75e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
76e41f4b71Sopenharmony_ci
77e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
78e41f4b71Sopenharmony_ci
79e41f4b71Sopenharmony_ci**Parameters**
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci| Name| Type                    | Mandatory| Description                 |
82e41f4b71Sopenharmony_ci| ------ | ------------------------ | ---- | --------------------- |
83e41f4b71Sopenharmony_ci| value  | [Font](ts-types.md#font) | No  | Placeholder text style.|
84e41f4b71Sopenharmony_ci
85e41f4b71Sopenharmony_ci### textFont
86e41f4b71Sopenharmony_ci
87e41f4b71Sopenharmony_citextFont(value?: Font)
88e41f4b71Sopenharmony_ci
89e41f4b71Sopenharmony_ciSets the style of the text entered in the search box, including the font size, font width, font family, and font style. Currently, only the default font family is supported.
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
92e41f4b71Sopenharmony_ci
93e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
94e41f4b71Sopenharmony_ci
95e41f4b71Sopenharmony_ci**Parameters**
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci| Name| Type                    | Mandatory| Description                  |
98e41f4b71Sopenharmony_ci| ------ | ------------------------ | ---- | ---------------------- |
99e41f4b71Sopenharmony_ci| value  | [Font](ts-types.md#font) | No  | Text font of the search text box.|
100e41f4b71Sopenharmony_ci
101e41f4b71Sopenharmony_ci### textAlign<sup>9+</sup>
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_citextAlign(value: TextAlign)
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ciSets the text alignment mode in the search text box. Currently, the following alignment modes are supported: **Start**, **Center**, and **End**.
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
108e41f4b71Sopenharmony_ci
109e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
110e41f4b71Sopenharmony_ci
111e41f4b71Sopenharmony_ci**Parameters**
112e41f4b71Sopenharmony_ci
113e41f4b71Sopenharmony_ci| Name| Type                                       | Mandatory| Description                                                  |
114e41f4b71Sopenharmony_ci| ------ | ------------------------------------------- | ---- | ------------------------------------------------------ |
115e41f4b71Sopenharmony_ci| value  | [TextAlign](ts-appendix-enums.md#textalign) | Yes  | Text alignment mode in the search text box.<br>Default value: **TextAlign.Start**|
116e41f4b71Sopenharmony_ci
117e41f4b71Sopenharmony_ci### copyOption<sup>9+</sup>
118e41f4b71Sopenharmony_ci
119e41f4b71Sopenharmony_cicopyOption(value: CopyOptions)
120e41f4b71Sopenharmony_ci
121e41f4b71Sopenharmony_ciSets whether copy and paste is allowed. If this attribute is set to **CopyOptions.None**, the text can be pasted, but copy or cut is not allowed. 
122e41f4b71Sopenharmony_ci
123e41f4b71Sopenharmony_ciDragging is not allowed when **CopyOptions.None** is set.
124e41f4b71Sopenharmony_ci
125e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
128e41f4b71Sopenharmony_ci
129e41f4b71Sopenharmony_ci**Parameters**
130e41f4b71Sopenharmony_ci
131e41f4b71Sopenharmony_ci| Name| Type                                            | Mandatory| Description                                                        |
132e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------ | ---- | ------------------------------------------------------------ |
133e41f4b71Sopenharmony_ci| value  | [CopyOptions](ts-appendix-enums.md#copyoptions9) | Yes  | Whether copy and paste is allowed.<br>Default value: **CopyOptions.LocalDevice**|
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ci### searchIcon<sup>10+</sup>
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_cisearchIcon(value: IconOptions | SymbolGlyphModifier)
138e41f4b71Sopenharmony_ci
139e41f4b71Sopenharmony_ciSets the style of the search icon on the left.
140e41f4b71Sopenharmony_ci
141e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ci**Parameters**
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci| Name| Type                                 | Mandatory| Description              |
148e41f4b71Sopenharmony_ci| ------ | ------------------------------------- | ---- | ------------------ |
149e41f4b71Sopenharmony_ci| value  | [IconOptions](#iconoptions10) \| [SymbolGlyphModifier](ts-universal-attributes-attribute-modifier.md) | Yes  | Style of the search icon on the left.<!--RP1--><br>Default value in light mode:<br>{<br>size: '16vp',<br>color: '#99182431',<br>src: ' '<br>}<br>Default value in dark mode:<br>{<br>size: '16vp',<br>color: '#99ffffff',<br>src: ' '<br>} <!--RP1End-->|
150e41f4b71Sopenharmony_ci
151e41f4b71Sopenharmony_ci### cancelButton<sup>10+</sup>
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_cicancelButton(value: CancelButtonOptions | CancelButtonSymbolOptions)
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ciSets the style of the Cancel button on the right.
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
158e41f4b71Sopenharmony_ci
159e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
160e41f4b71Sopenharmony_ci
161e41f4b71Sopenharmony_ci**Parameters**
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description                                                        |
164e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
165e41f4b71Sopenharmony_ci| value  | [CancelButtonOptions](#cancelbuttonoptions12) \| [CancelButtonSymbolOptions](#cancelbuttonsymboloptions12) | Yes  | Style of the Cancel button on the right.<br>Default value:<br>{<br>style: CancelButtonStyle.INPUT,<br>icon: {<br>size: '16vp',<br>color: '#99ffffff',<br>src: ' '<br>}<br>}<br>When **style** is set to **CancelButtonStyle.CONSTANT**, the Cancel button is always displayed.|
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci### fontColor<sup>10+</sup>
168e41f4b71Sopenharmony_ci
169e41f4b71Sopenharmony_cifontColor(value: ResourceColor)
170e41f4b71Sopenharmony_ci
171e41f4b71Sopenharmony_ciSets the font color of the input text. [Universal text attributes](ts-universal-attributes-text-style.md) **fontSize**, **fontStyle**, **fontWeight**, and **fontFamily** are set in the [textFont](#textfont) attribute.
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci**Parameters**
178e41f4b71Sopenharmony_ci
179e41f4b71Sopenharmony_ci| Name| Type                                      | Mandatory| Description                                           |
180e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ----------------------------------------------- |
181e41f4b71Sopenharmony_ci| value  | [ResourceColor](ts-types.md#resourcecolor) | Yes  | Font color of the input text.<br>Default value: **'#FF182431'**|
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci### caretStyle<sup>10+</sup>
184e41f4b71Sopenharmony_ci
185e41f4b71Sopenharmony_cicaretStyle(value: CaretStyle)
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ciSets the caret style.
188e41f4b71Sopenharmony_ci
189e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
190e41f4b71Sopenharmony_ci
191e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
192e41f4b71Sopenharmony_ci
193e41f4b71Sopenharmony_ci**Parameters**
194e41f4b71Sopenharmony_ci
195e41f4b71Sopenharmony_ci| Name| Type                               | Mandatory| Description                                                        |
196e41f4b71Sopenharmony_ci| ------ | ----------------------------------- | ---- | ------------------------------------------------------------ |
197e41f4b71Sopenharmony_ci| value  | [CaretStyle](ts-text-common.md#caretstyle10) | Yes  | Caret style.<br>Default value:<br>{<br>width: '1.5vp',<br>color: '#007DFF'<br>} |
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci>  **NOTE**    
200e41f4b71Sopenharmony_ci>   Since API version 12, this API can be used to set the text handle color, which is the same as the caret color.
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci### enableKeyboardOnFocus<sup>10+</sup>
203e41f4b71Sopenharmony_ci
204e41f4b71Sopenharmony_cienableKeyboardOnFocus(value: boolean)
205e41f4b71Sopenharmony_ci
206e41f4b71Sopenharmony_ciSets whether to enable the input method when the component obtains focus in a way other than clicking.
207e41f4b71Sopenharmony_ci
208e41f4b71Sopenharmony_ci 
209e41f4b71Sopenharmony_ci
210e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
211e41f4b71Sopenharmony_ci
212e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
213e41f4b71Sopenharmony_ci
214e41f4b71Sopenharmony_ci**Parameters**
215e41f4b71Sopenharmony_ci
216e41f4b71Sopenharmony_ci| Name| Type   | Mandatory| Description                                           |
217e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ----------------------------------------------- |
218e41f4b71Sopenharmony_ci| value  | boolean | Yes  | Whether to enable the input method when the component obtains focus.<br>Default value: **true**|
219e41f4b71Sopenharmony_ci
220e41f4b71Sopenharmony_ci### selectionMenuHidden<sup>10+</sup>
221e41f4b71Sopenharmony_ci
222e41f4b71Sopenharmony_ciselectionMenuHidden(value: boolean)
223e41f4b71Sopenharmony_ci
224e41f4b71Sopenharmony_ciSets whether to hide the system text selection menu.
225e41f4b71Sopenharmony_ci
226e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
227e41f4b71Sopenharmony_ci
228e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
229e41f4b71Sopenharmony_ci
230e41f4b71Sopenharmony_ci**Parameters**
231e41f4b71Sopenharmony_ci
232e41f4b71Sopenharmony_ci| Name| Type   | Mandatory| Description                                                        |
233e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ------------------------------------------------------------ |
234e41f4b71Sopenharmony_ci| value  | boolean | Yes  | Whether to hide the system text selection menu.<br>**true**: Tapping, long-pressing, double-tapping, triple-tapping, or right-clicking the text box will not trigger the system text selection menu.<br>**false**: Tapping, long-pressing, double-tapping, triple-tapping, or right-clicking the text box will trigger the system text selection menu.<br>Default value: **false**|
235e41f4b71Sopenharmony_ci
236e41f4b71Sopenharmony_ci### customKeyboard<sup>10+</sup>
237e41f4b71Sopenharmony_ci
238e41f4b71Sopenharmony_cicustomKeyboard(value: CustomBuilder, options?: KeyboardOptions)
239e41f4b71Sopenharmony_ci
240e41f4b71Sopenharmony_ciCustom keyboard.
241e41f4b71Sopenharmony_ci
242e41f4b71Sopenharmony_ciWhen a custom keyboard is set, activating the text box opens the specified custom component, instead of the system input method.
243e41f4b71Sopenharmony_ci
244e41f4b71Sopenharmony_ciThe custom keyboard's height can be set through the **height** attribute of the custom component's root node, and its width is fixed at the default value.
245e41f4b71Sopenharmony_ci
246e41f4b71Sopenharmony_ciThe custom keyboard is presented by overlaying the original screen. It is not compressed or lifted if avoid mode is not enabled or avoidance is not needed for the text box.
247e41f4b71Sopenharmony_ci
248e41f4b71Sopenharmony_ciThe custom keyboard cannot obtain the focus, but it blocks gesture events.
249e41f4b71Sopenharmony_ci
250e41f4b71Sopenharmony_ciBy default, the custom keyboard is closed when the input component loses the focus. You can also use the [stopEditing](#stopediting10) API to close the keyboard.
251e41f4b71Sopenharmony_ci
252e41f4b71Sopenharmony_ciWhen a custom keyboard is set, the text box does not support camera input, even when the device supports.
253e41f4b71Sopenharmony_ci
254e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
255e41f4b71Sopenharmony_ci
256e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
257e41f4b71Sopenharmony_ci
258e41f4b71Sopenharmony_ci**Parameters**
259e41f4b71Sopenharmony_ci
260e41f4b71Sopenharmony_ci| Name               | Type                                       | Mandatory| Description                            |
261e41f4b71Sopenharmony_ci| --------------------- | ------------------------------------------- | ---- | -------------------------------- |
262e41f4b71Sopenharmony_ci| value                 | [CustomBuilder](ts-types.md#custombuilder8) | Yes  | Custom keyboard.                    |
263e41f4b71Sopenharmony_ci| options<sup>12+</sup> | [KeyboardOptions](ts-basic-components-richeditor.md#keyboardoptions12)       | No  | Whether to support keyboard avoidance.|
264e41f4b71Sopenharmony_ci
265e41f4b71Sopenharmony_ci### type<sup>11+</sup>
266e41f4b71Sopenharmony_ci
267e41f4b71Sopenharmony_citype(value: SearchType)
268e41f4b71Sopenharmony_ci
269e41f4b71Sopenharmony_ciSets the text box type.
270e41f4b71Sopenharmony_ci
271e41f4b71Sopenharmony_ci<br>**Atomic service API**: This API can be used in atomic services since API version 12.
272e41f4b71Sopenharmony_ci
273e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
274e41f4b71Sopenharmony_ci
275e41f4b71Sopenharmony_ci**Parameters**
276e41f4b71Sopenharmony_ci
277e41f4b71Sopenharmony_ci| Name| Type                               | Mandatory| Description                       |
278e41f4b71Sopenharmony_ci| ------ | ----------------------------------- | ---- | -------------------------- |
279e41f4b71Sopenharmony_ci| value  | [SearchType](#searchtype11) | Yes  | Text box type.<br>Default value: **SearchType.Normal**|
280e41f4b71Sopenharmony_ci
281e41f4b71Sopenharmony_ci### maxLength<sup>11+</sup>
282e41f4b71Sopenharmony_ci
283e41f4b71Sopenharmony_cimaxLength(value: number)
284e41f4b71Sopenharmony_ci
285e41f4b71Sopenharmony_ciSets the maximum number of characters for text input. By default, there is no maximum number of characters. When the maximum number is reached, no more characters can be entered.
286e41f4b71Sopenharmony_ci
287e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
288e41f4b71Sopenharmony_ci
289e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
290e41f4b71Sopenharmony_ci
291e41f4b71Sopenharmony_ci**Parameters**
292e41f4b71Sopenharmony_ci
293e41f4b71Sopenharmony_ci| Name| Type                               | Mandatory| Description                  |
294e41f4b71Sopenharmony_ci| ------ | ----------------------------------- | ---- | ---------------------- |
295e41f4b71Sopenharmony_ci| value  | number | Yes  | Maximum number of characters for text input.|
296e41f4b71Sopenharmony_ci
297e41f4b71Sopenharmony_ci### enterKeyType<sup>12+</sup>
298e41f4b71Sopenharmony_ci
299e41f4b71Sopenharmony_cienterKeyType(value: EnterKeyType)
300e41f4b71Sopenharmony_ci
301e41f4b71Sopenharmony_ciSets the type of the Enter key.
302e41f4b71Sopenharmony_ci
303e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
304e41f4b71Sopenharmony_ci
305e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
306e41f4b71Sopenharmony_ci
307e41f4b71Sopenharmony_ci**Parameters**
308e41f4b71Sopenharmony_ci
309e41f4b71Sopenharmony_ci| Name| Type                                            | Mandatory| Description                                              |
310e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------ | ---- | -------------------------------------------------- |
311e41f4b71Sopenharmony_ci| value  | [EnterKeyType](ts-types.md#enterkeytype) | Yes  | Type of the Enter key.<br>Default value: **EnterKeyType.Search**|
312e41f4b71Sopenharmony_ci
313e41f4b71Sopenharmony_ci### lineHeight<sup>12+</sup>
314e41f4b71Sopenharmony_ci
315e41f4b71Sopenharmony_cilineHeight(value: number | string | Resource)
316e41f4b71Sopenharmony_ci
317e41f4b71Sopenharmony_ciSets the text line height. If the value is less than or equal to **0**, the line height is not limited and the font size is adaptive. If the value is of the number type, the unit fp is used.
318e41f4b71Sopenharmony_ci
319e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
320e41f4b71Sopenharmony_ci
321e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
322e41f4b71Sopenharmony_ci
323e41f4b71Sopenharmony_ci**Parameters**
324e41f4b71Sopenharmony_ci
325e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description            |
326e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ---------------- |
327e41f4b71Sopenharmony_ci| value  | number \| string \| [Resource](ts-types.md#resource) | Yes  | Text line height.|
328e41f4b71Sopenharmony_ci
329e41f4b71Sopenharmony_ci### decoration<sup>12+</sup>
330e41f4b71Sopenharmony_ci
331e41f4b71Sopenharmony_cidecoration(value: TextDecorationOptions)
332e41f4b71Sopenharmony_ci
333e41f4b71Sopenharmony_ciSets the color, type, and style of the text decorative line.
334e41f4b71Sopenharmony_ci
335e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
336e41f4b71Sopenharmony_ci
337e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
338e41f4b71Sopenharmony_ci
339e41f4b71Sopenharmony_ci**Parameters**
340e41f4b71Sopenharmony_ci
341e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description                                                        |
342e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
343e41f4b71Sopenharmony_ci| value  | [TextDecorationOptions](ts-types.md#textdecorationoptions12) | Yes  | Text decorative line options.<br>Default value: {<br> type: TextDecorationType.None,<br> color: Color.Black,<br> style: TextDecorationStyle.SOLID <br>} |
344e41f4b71Sopenharmony_ci
345e41f4b71Sopenharmony_ci### letterSpacing<sup>12+</sup>
346e41f4b71Sopenharmony_ci
347e41f4b71Sopenharmony_ciletterSpacing(value: number | string | Resource)
348e41f4b71Sopenharmony_ci
349e41f4b71Sopenharmony_ciSets the letter spacing for a text style. If the value specified is a percentage or 0, the default value is used.
350e41f4b71Sopenharmony_ci
351e41f4b71Sopenharmony_ciIf the value specified is a negative value, the text is compressed. A negative value too small may result in the text being compressed to 0 and no content being displayed.
352e41f4b71Sopenharmony_ci
353e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
354e41f4b71Sopenharmony_ci
355e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
356e41f4b71Sopenharmony_ci
357e41f4b71Sopenharmony_ci**Parameters**
358e41f4b71Sopenharmony_ci
359e41f4b71Sopenharmony_ci| Name| Type                      | Mandatory| Description          |
360e41f4b71Sopenharmony_ci| ------ | -------------------------- | ---- | -------------- |
361e41f4b71Sopenharmony_ci| value  | number \| string \| [Resource](ts-types.md#resource) | Yes  | Letter spacing.|
362e41f4b71Sopenharmony_ci
363e41f4b71Sopenharmony_ci### fontFeature<sup>12+</sup>
364e41f4b71Sopenharmony_ci
365e41f4b71Sopenharmony_cifontFeature(value: string)
366e41f4b71Sopenharmony_ci
367e41f4b71Sopenharmony_ciSets the font feature, for example, monospaced digits.
368e41f4b71Sopenharmony_ci
369e41f4b71Sopenharmony_ciFormat: normal \| \<feature-tag-value\>
370e41f4b71Sopenharmony_ci
371e41f4b71Sopenharmony_ciFormat of **\<feature-tag-value\>**: \<string\> \[ \<integer\> \| on \| off ]
372e41f4b71Sopenharmony_ci
373e41f4b71Sopenharmony_ciThere can be multiple **\<feature-tag-value\>** values, which are separated by commas (,).
374e41f4b71Sopenharmony_ci
375e41f4b71Sopenharmony_ciFor example, the input format for monospaced clock fonts is "ss01" on.
376e41f4b71Sopenharmony_ci
377e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
378e41f4b71Sopenharmony_ci
379e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
380e41f4b71Sopenharmony_ci
381e41f4b71Sopenharmony_ci**Parameters**
382e41f4b71Sopenharmony_ci
383e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description          |
384e41f4b71Sopenharmony_ci| ------ | ------ | ---- | -------------- |
385e41f4b71Sopenharmony_ci| value  | string | Yes  | Font feature.|
386e41f4b71Sopenharmony_ci
387e41f4b71Sopenharmony_ciFor details about the supported font features, see [Font Feature List](ts-basic-components-text.md#fontfeature12).
388e41f4b71Sopenharmony_ciFont features are advanced typographic features, such as ligatures and monospace, for OpenType fonts. They are typically used in custom fonts and require the support of the font itself.
389e41f4b71Sopenharmony_ciFor more information about the font features, see [Low-level font feature settings control: the font-feature-settings property](https://www.w3.org/TR/css-fonts-3/#font-feature-settings-prop) and [The Complete CSS Demo for OpenType Features](https://sparanoid.com/lab/opentype-features/).
390e41f4b71Sopenharmony_ci
391e41f4b71Sopenharmony_ci### selectedBackgroundColor<sup>12+</sup>
392e41f4b71Sopenharmony_ci
393e41f4b71Sopenharmony_ciselectedBackgroundColor(value: ResourceColor)
394e41f4b71Sopenharmony_ci
395e41f4b71Sopenharmony_ciSets the background color of the selected text. If the opacity is not set, a 20% opacity will be used.
396e41f4b71Sopenharmony_ci
397e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
398e41f4b71Sopenharmony_ci
399e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
400e41f4b71Sopenharmony_ci
401e41f4b71Sopenharmony_ci**Parameters**
402e41f4b71Sopenharmony_ci
403e41f4b71Sopenharmony_ci| Name| Type                                      | Mandatory| Description                                      |
404e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ------------------------------------------ |
405e41f4b71Sopenharmony_ci| value  | [ResourceColor](ts-types.md#resourcecolor) | Yes  | Background color of the selected text.<br>By default, a 20% opacity is applied.|
406e41f4b71Sopenharmony_ci
407e41f4b71Sopenharmony_ci### inputFilter<sup>12+</sup>
408e41f4b71Sopenharmony_ci
409e41f4b71Sopenharmony_ciinputFilter(value: ResourceStr, error?:  Callback< string >)
410e41f4b71Sopenharmony_ci
411e41f4b71Sopenharmony_ciSets the regular expression for input filtering. Only inputs that comply with the regular expression can be displayed. Other inputs are filtered out. The specified regular expression can match single characters, but not strings.
412e41f4b71Sopenharmony_ci
413e41f4b71Sopenharmony_ciIf **inputFilter** is set and the entered characters are not null, the filtering effect attached to the text box type (specified through the **type** attribute) does not take effect.
414e41f4b71Sopenharmony_ci
415e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
416e41f4b71Sopenharmony_ci
417e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
418e41f4b71Sopenharmony_ci
419e41f4b71Sopenharmony_ci**Parameters**
420e41f4b71Sopenharmony_ci
421e41f4b71Sopenharmony_ci| Name| Type                                  | Mandatory| Description                              |
422e41f4b71Sopenharmony_ci| ------ | -------------------------------------- | ---- | ---------------------------------- |
423e41f4b71Sopenharmony_ci| value  | [ResourceStr](ts-types.md#resourcestr) | Yes  | Regular expression.                      |
424e41f4b71Sopenharmony_ci| error  |  Callback< string >     | No  | Filtered-out content to return when regular expression matching fails.|
425e41f4b71Sopenharmony_ci
426e41f4b71Sopenharmony_ci### textIndent<sup>12+</sup>
427e41f4b71Sopenharmony_ci
428e41f4b71Sopenharmony_citextIndent(value: Dimension)
429e41f4b71Sopenharmony_ci
430e41f4b71Sopenharmony_ciSets the indent of the first line text.
431e41f4b71Sopenharmony_ci
432e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
433e41f4b71Sopenharmony_ci
434e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
435e41f4b71Sopenharmony_ci
436e41f4b71Sopenharmony_ci**Parameters**
437e41f4b71Sopenharmony_ci
438e41f4b71Sopenharmony_ci| Name| Type                                | Mandatory| Description                        |
439e41f4b71Sopenharmony_ci| ------ | ----------------------------------- | ---- | ---------------------------- |
440e41f4b71Sopenharmony_ci| value  | [Dimension](ts-types.md#dimension10)| Yes  | Indent of the first line text.<br>Default value: **0**  |
441e41f4b71Sopenharmony_ci
442e41f4b71Sopenharmony_ci### minFontSize<sup>12+</sup>
443e41f4b71Sopenharmony_ci
444e41f4b71Sopenharmony_ciminFontSize(value: number | string | Resource)
445e41f4b71Sopenharmony_ci
446e41f4b71Sopenharmony_ciSets the minimum font size.
447e41f4b71Sopenharmony_ci
448e41f4b71Sopenharmony_ciFor the setting to take effect, this attribute must be used together with [maxFontSize](#maxfontsize12) or layout constraint settings.
449e41f4b71Sopenharmony_ci
450e41f4b71Sopenharmony_ciWhen the adaptive font size is used, the **fontSize** settings do not take effect.
451e41f4b71Sopenharmony_ci
452e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
453e41f4b71Sopenharmony_ci
454e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
455e41f4b71Sopenharmony_ci
456e41f4b71Sopenharmony_ci**Parameters**
457e41f4b71Sopenharmony_ci
458e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description              |
459e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------ |
460e41f4b71Sopenharmony_ci| value  | number \| string \| [Resource](ts-types.md#resource) | Yes  | Minimum font size.|
461e41f4b71Sopenharmony_ci
462e41f4b71Sopenharmony_ci### maxFontSize<sup>12+</sup>
463e41f4b71Sopenharmony_ci
464e41f4b71Sopenharmony_cimaxFontSize(value: number | string | Resource)
465e41f4b71Sopenharmony_ci
466e41f4b71Sopenharmony_ciSets the maximum font size.
467e41f4b71Sopenharmony_ci
468e41f4b71Sopenharmony_ciFor the setting to take effect, this attribute must be used together with [minFontSize](#minfontsize12) or layout constraint settings.
469e41f4b71Sopenharmony_ci
470e41f4b71Sopenharmony_ciWhen the adaptive font size is used, the **fontSize** settings do not take effect.
471e41f4b71Sopenharmony_ci
472e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
473e41f4b71Sopenharmony_ci
474e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
475e41f4b71Sopenharmony_ci
476e41f4b71Sopenharmony_ci**Parameters**
477e41f4b71Sopenharmony_ci
478e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description              |
479e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------ |
480e41f4b71Sopenharmony_ci| value  | number \| string \| [Resource](ts-types.md#resource) | Yes  | Maximum font size.|
481e41f4b71Sopenharmony_ci
482e41f4b71Sopenharmony_ci### editMenuOptions<sup>12+</sup>
483e41f4b71Sopenharmony_ci
484e41f4b71Sopenharmony_cieditMenuOptions(editMenu: EditMenuOptions)
485e41f4b71Sopenharmony_ci
486e41f4b71Sopenharmony_ciSets the extended options of the custom context menu on selection, including the text content, icon, and callback.
487e41f4b71Sopenharmony_ci
488e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
489e41f4b71Sopenharmony_ci
490e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
491e41f4b71Sopenharmony_ci
492e41f4b71Sopenharmony_ci**Parameters**
493e41f4b71Sopenharmony_ci
494e41f4b71Sopenharmony_ci| Name| Type                                         | Mandatory| Description                                         |
495e41f4b71Sopenharmony_ci| ------ | --------------------------------------------- | ---- | --------------------------------------------- |
496e41f4b71Sopenharmony_ci| editMenu  | [EditMenuOptions](ts-text-common.md#editmenuoptions) | Yes  | Extended options of the custom context menu on selection.|
497e41f4b71Sopenharmony_ci
498e41f4b71Sopenharmony_ci### enablePreviewText<sup>12+</sup>
499e41f4b71Sopenharmony_ci
500e41f4b71Sopenharmony_cienablePreviewText(enable: boolean)
501e41f4b71Sopenharmony_ci
502e41f4b71Sopenharmony_ciSets whether to enable preview text.
503e41f4b71Sopenharmony_ci
504e41f4b71Sopenharmony_ciPreview text is in a temporary state and does not support text interception. As such, it does not trigger **onWillInsert**, **onDidInsert**, **onWillDelete**, or **onDidDelete** callbacks.
505e41f4b71Sopenharmony_ci
506e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
507e41f4b71Sopenharmony_ci
508e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
509e41f4b71Sopenharmony_ci
510e41f4b71Sopenharmony_ci**Parameters**
511e41f4b71Sopenharmony_ci
512e41f4b71Sopenharmony_ci| Name| Type   | Mandatory| Description                              |
513e41f4b71Sopenharmony_ci| ------ | ------- | ---- | ---------------------------------- |
514e41f4b71Sopenharmony_ci| enable | boolean | Yes  | Whether to enable preview text.<br>Default value: **true**|
515e41f4b71Sopenharmony_ci
516e41f4b71Sopenharmony_ci## IconOptions<sup>10+</sup>
517e41f4b71Sopenharmony_ci
518e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
519e41f4b71Sopenharmony_ci
520e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
521e41f4b71Sopenharmony_ci
522e41f4b71Sopenharmony_ci| Name| Type                                  | Mandatory| Description   |
523e41f4b71Sopenharmony_ci| ------ | ------------------------------------------ | ---- | ----------- |
524e41f4b71Sopenharmony_ci| size   | [Length](ts-types.md#length)               | No  | Icon size. It cannot be set in percentage.   |
525e41f4b71Sopenharmony_ci| color  | [ResourceColor](ts-types.md#resourcecolor) | No  | Icon color.   |
526e41f4b71Sopenharmony_ci| src    | [ResourceStr](ts-types.md#resourcestr)     | No  | Image source of the icon.|
527e41f4b71Sopenharmony_ci
528e41f4b71Sopenharmony_ci## SearchButtonOptions<sup>10+</sup>
529e41f4b71Sopenharmony_ci
530e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
531e41f4b71Sopenharmony_ci
532e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
533e41f4b71Sopenharmony_ci
534e41f4b71Sopenharmony_ci| Name   | Type                                  | Mandatory| Description        |
535e41f4b71Sopenharmony_ci| --------- | ------------------------------------------ | ---- | ---------------- |
536e41f4b71Sopenharmony_ci| fontSize  | [Length](ts-types.md#length)               | No  | Font size of the button. It cannot be set in percentage.|
537e41f4b71Sopenharmony_ci| fontColor | [ResourceColor](ts-types.md#resourcecolor) | No  | Font color of the button.|
538e41f4b71Sopenharmony_ci
539e41f4b71Sopenharmony_ci## CancelButtonStyle<sup>10+</sup>
540e41f4b71Sopenharmony_ci
541e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
542e41f4b71Sopenharmony_ci
543e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
544e41f4b71Sopenharmony_ci
545e41f4b71Sopenharmony_ci| Name                   | Description            |
546e41f4b71Sopenharmony_ci| ----------------------- | ---------------- |
547e41f4b71Sopenharmony_ci| CONSTANT  | The Cancel button is always displayed.|
548e41f4b71Sopenharmony_ci| INVISIBLE | The Cancel button is always hidden.|
549e41f4b71Sopenharmony_ci| INPUT     | The Cancel button is displayed when there is text input.|
550e41f4b71Sopenharmony_ci
551e41f4b71Sopenharmony_ci## SearchType<sup>11+</sup>
552e41f4b71Sopenharmony_ci
553e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
554e41f4b71Sopenharmony_ci
555e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
556e41f4b71Sopenharmony_ci
557e41f4b71Sopenharmony_ci| Name                | Value           | Description           |
558e41f4b71Sopenharmony_ci| ------------------ | ------ | ------------- |
559e41f4b71Sopenharmony_ci| NORMAL   | 0 | Normal input mode.<br>The value can contain digits, letters, underscores (_), spaces, and special characters.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
560e41f4b71Sopenharmony_ci| NUMBER   | 2 | Digit input mode.<br>**Atomic service API**: This API can be used in atomic services since API version 12.     |
561e41f4b71Sopenharmony_ci| PHONE_NUMBER | 3 | Phone number input mode.<br>In this mode, the following are allowed: digits, spaces, plus signs (+), hyphens (-), asterisks (*), and number signs (#); the length is not limited.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
562e41f4b71Sopenharmony_ci| EMAIL    | 5 | Email address input mode.<br>This mode accepts only digits, letters, underscores (_), dots (.), and the following special characters: ! # $ % & ' * + - / = ? ^ ` \{ \| \} ~ @ (which can only appear once)<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
563e41f4b71Sopenharmony_ci| NUMBER_DECIMAL<sup>12+</sup>  | 12 | Number input mode with a decimal point.<br>The value can contain digits and one decimal point.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
564e41f4b71Sopenharmony_ci| URL<sup>12+</sup>  | 13 | URL input mode.<br>**Atomic service API**: This API can be used in atomic services since API version 12.|
565e41f4b71Sopenharmony_ci
566e41f4b71Sopenharmony_ci## CancelButtonOptions<sup>12+</sup>
567e41f4b71Sopenharmony_ci
568e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
569e41f4b71Sopenharmony_ci
570e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
571e41f4b71Sopenharmony_ci
572e41f4b71Sopenharmony_ci| Name   | Type                                  | Mandatory| Description        |
573e41f4b71Sopenharmony_ci| --------- | ------------------------------------------ | ---- | ---------------- |
574e41f4b71Sopenharmony_ci| style  | [CancelButtonStyle](#cancelbuttonstyle10)               | No  | Display state of the Cancel button on the right.|
575e41f4b71Sopenharmony_ci| icon | [IconOptions](#iconoptions10) | No  | Icon of the Cancel button on the right.|
576e41f4b71Sopenharmony_ci
577e41f4b71Sopenharmony_ci## CancelButtonSymbolOptions<sup>12+</sup>
578e41f4b71Sopenharmony_ci
579e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
580e41f4b71Sopenharmony_ci
581e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
582e41f4b71Sopenharmony_ci
583e41f4b71Sopenharmony_ci| Name   | Type                                  | Mandatory| Description        |
584e41f4b71Sopenharmony_ci| --------- | ------------------------------------------ | ---- | ---------------- |
585e41f4b71Sopenharmony_ci| style  | [CancelButtonStyle](#cancelbuttonstyle10)               | No  | Display state of the Cancel button on the right.|
586e41f4b71Sopenharmony_ci| icon | [SymbolGlyphModifier](ts-universal-attributes-attribute-modifier.md) | No  | Symbol icon of the Cancel button on the right.|
587e41f4b71Sopenharmony_ci
588e41f4b71Sopenharmony_ci## Events
589e41f4b71Sopenharmony_ci
590e41f4b71Sopenharmony_ciIn addition to the [universal events](ts-universal-events-click.md), the following events are supported.
591e41f4b71Sopenharmony_ci
592e41f4b71Sopenharmony_ci### onSubmit
593e41f4b71Sopenharmony_ci
594e41f4b71Sopenharmony_cionSubmit(callback: (value: string) => void)
595e41f4b71Sopenharmony_ci
596e41f4b71Sopenharmony_ciInvoked when users click the search icon or the search button, or touch the search button on a soft keyboard.
597e41f4b71Sopenharmony_ci
598e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
599e41f4b71Sopenharmony_ci
600e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
601e41f4b71Sopenharmony_ci
602e41f4b71Sopenharmony_ci**Parameters**
603e41f4b71Sopenharmony_ci
604e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                        |
605e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------------- |
606e41f4b71Sopenharmony_ci| value  | string | Yes  | Current text input.|
607e41f4b71Sopenharmony_ci
608e41f4b71Sopenharmony_ci### onChange
609e41f4b71Sopenharmony_ci
610e41f4b71Sopenharmony_cionChange(callback: EditableTextOnChangeCallback)
611e41f4b71Sopenharmony_ci
612e41f4b71Sopenharmony_ciInvoked when the input in the text box changes.
613e41f4b71Sopenharmony_ci
614e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
615e41f4b71Sopenharmony_ci
616e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
617e41f4b71Sopenharmony_ci
618e41f4b71Sopenharmony_ci**Parameters**
619e41f4b71Sopenharmony_ci
620e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description                        |
621e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------------------- |
622e41f4b71Sopenharmony_ci| callback  | [EditableTextOnChangeCallback](ts-text-common.md#editabletextonchangecallback12) | Yes  | Callback invoked when the input in the text box changes.|
623e41f4b71Sopenharmony_ci
624e41f4b71Sopenharmony_ci### onCopy
625e41f4b71Sopenharmony_ci
626e41f4b71Sopenharmony_cionCopy(callback: (value: string) => void)
627e41f4b71Sopenharmony_ci
628e41f4b71Sopenharmony_ciInvoked when a copy operation is performed.
629e41f4b71Sopenharmony_ci
630e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
631e41f4b71Sopenharmony_ci
632e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
633e41f4b71Sopenharmony_ci
634e41f4b71Sopenharmony_ci**Parameters**
635e41f4b71Sopenharmony_ci
636e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description            |
637e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------- |
638e41f4b71Sopenharmony_ci| value  | string | Yes  | Text that is copied.|
639e41f4b71Sopenharmony_ci
640e41f4b71Sopenharmony_ci### onCut
641e41f4b71Sopenharmony_ci
642e41f4b71Sopenharmony_cionCut(callback: (value: string) => void)
643e41f4b71Sopenharmony_ci
644e41f4b71Sopenharmony_ciInvoked when a cut operation is performed.
645e41f4b71Sopenharmony_ci
646e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
647e41f4b71Sopenharmony_ci
648e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
649e41f4b71Sopenharmony_ci
650e41f4b71Sopenharmony_ci**Parameters**
651e41f4b71Sopenharmony_ci
652e41f4b71Sopenharmony_ci| Name| Type  | Mandatory| Description            |
653e41f4b71Sopenharmony_ci| ------ | ------ | ---- | ---------------- |
654e41f4b71Sopenharmony_ci| value  | string | Yes  | Text that is cut.|
655e41f4b71Sopenharmony_ci
656e41f4b71Sopenharmony_ci### onPaste
657e41f4b71Sopenharmony_ci
658e41f4b71Sopenharmony_cionPaste(callback: (value: string, event: PasteEvent) => void)
659e41f4b71Sopenharmony_ci
660e41f4b71Sopenharmony_ciInvoked when a paste operation is performed.
661e41f4b71Sopenharmony_ci
662e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
663e41f4b71Sopenharmony_ci
664e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
665e41f4b71Sopenharmony_ci
666e41f4b71Sopenharmony_ci**Parameters**
667e41f4b71Sopenharmony_ci
668e41f4b71Sopenharmony_ci| Name             | Type                                                        | Mandatory| Description                  |
669e41f4b71Sopenharmony_ci| ------------------- | ------------------------------------------------------------ | ---- | ---------------------- |
670e41f4b71Sopenharmony_ci| value               | string                                                       | Yes  | Text to be pasted.      |
671e41f4b71Sopenharmony_ci| event<sup>11+</sup> | [PasteEvent](ts-basic-components-richeditor.md#pasteevent11) | Yes  | Custom paste event.|
672e41f4b71Sopenharmony_ci
673e41f4b71Sopenharmony_ci### onTextSelectionChange<sup>10+</sup>
674e41f4b71Sopenharmony_ci
675e41f4b71Sopenharmony_cionTextSelectionChange(callback: (selectionStart: number, selectionEnd: number) => void)
676e41f4b71Sopenharmony_ci
677e41f4b71Sopenharmony_ciInvoked when the position of the text selection changes or when the cursor position changes during the editing state.
678e41f4b71Sopenharmony_ci
679e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
680e41f4b71Sopenharmony_ci
681e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
682e41f4b71Sopenharmony_ci
683e41f4b71Sopenharmony_ci**Parameters**
684e41f4b71Sopenharmony_ci
685e41f4b71Sopenharmony_ci| Name        | Type  | Mandatory| Description                                             |
686e41f4b71Sopenharmony_ci| -------------- | ------ | ---- | ------------------------------------------------- |
687e41f4b71Sopenharmony_ci| selectionStart | number | Yes  | Start position of the text selection range. The start position of text in the text box is 0.|
688e41f4b71Sopenharmony_ci| selectionEnd   | number | Yes  | End position of the text selection range.                           |
689e41f4b71Sopenharmony_ci
690e41f4b71Sopenharmony_ci### onContentScroll<sup>10+</sup>
691e41f4b71Sopenharmony_ci
692e41f4b71Sopenharmony_cionContentScroll(callback: (totalOffsetX: number, totalOffsetY: number) => void)
693e41f4b71Sopenharmony_ci
694e41f4b71Sopenharmony_ciInvoked when the text content is scrolled.
695e41f4b71Sopenharmony_ci
696e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
697e41f4b71Sopenharmony_ci
698e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
699e41f4b71Sopenharmony_ci
700e41f4b71Sopenharmony_ci**Parameters**
701e41f4b71Sopenharmony_ci
702e41f4b71Sopenharmony_ci| Name      | Type  | Mandatory| Description                              |
703e41f4b71Sopenharmony_ci| ------------ | ------ | ---- | ---------------------------------- |
704e41f4b71Sopenharmony_ci| totalOffsetX | number | Yes  | Offset in the X coordinate of the text in the content area, in px.|
705e41f4b71Sopenharmony_ci| totalOffsetY | number | Yes  | Offset in the Y coordinate of the text in the content area, in px.|
706e41f4b71Sopenharmony_ci
707e41f4b71Sopenharmony_ci### onEditChange<sup>12+</sup>
708e41f4b71Sopenharmony_ci
709e41f4b71Sopenharmony_cionEditChange(callback: Callback< boolean >)
710e41f4b71Sopenharmony_ci
711e41f4b71Sopenharmony_ciInvoked when the input status changes. The text box is in the editing state when it has the caret placed in it, and is in the non-editing state otherwise. If the value of **isEditing** is **true**, the text box is in the editing state.
712e41f4b71Sopenharmony_ci
713e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
714e41f4b71Sopenharmony_ci
715e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
716e41f4b71Sopenharmony_ci
717e41f4b71Sopenharmony_ci**Parameters**
718e41f4b71Sopenharmony_ci
719e41f4b71Sopenharmony_ci| Name   | Type                               | Mandatory| Description                |
720e41f4b71Sopenharmony_ci| --------- | ---------------------------------- | ---- | -------------------- |
721e41f4b71Sopenharmony_ci| isEditing |  Callback< boolean > | Yes  | Whether the text box is in the editing state. The value **true** indicates that the text box is in the editing state.|
722e41f4b71Sopenharmony_ci
723e41f4b71Sopenharmony_ci### onWillInsert<sup>12+</sup>
724e41f4b71Sopenharmony_ci
725e41f4b71Sopenharmony_cionWillInsert(callback: Callback\<InsertValue, boolean>)
726e41f4b71Sopenharmony_ci
727e41f4b71Sopenharmony_ciInvoked when text is about to be inserted.
728e41f4b71Sopenharmony_ci
729e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
730e41f4b71Sopenharmony_ci
731e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
732e41f4b71Sopenharmony_ci
733e41f4b71Sopenharmony_ci**Parameters**
734e41f4b71Sopenharmony_ci
735e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description              |
736e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------ |
737e41f4b71Sopenharmony_ci| callback  | Callback\<[InsertValue](ts-text-common.md#insertvalue12), boolean> | Yes  | Callback invoked when text is about to be inserted.<br>It returns **true** if the text is inserted; returns **false** otherwise.<br>This callback is not invoked for text preview.<br>It is available only for system input methods.|
738e41f4b71Sopenharmony_ci
739e41f4b71Sopenharmony_ci### onDidInsert<sup>12+</sup>
740e41f4b71Sopenharmony_ci
741e41f4b71Sopenharmony_cionDidInsert(callback: Callback\<InsertValue>)
742e41f4b71Sopenharmony_ci
743e41f4b71Sopenharmony_ciInvoked when text is inserted.
744e41f4b71Sopenharmony_ci
745e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
746e41f4b71Sopenharmony_ci
747e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
748e41f4b71Sopenharmony_ci
749e41f4b71Sopenharmony_ci**Parameters**
750e41f4b71Sopenharmony_ci
751e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description              |
752e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------ |
753e41f4b71Sopenharmony_ci| callback  | Callback\<[InsertValue](ts-text-common.md#insertvalue12)> | Yes  | Callback invoked when text is inserted.<br>It is available only for system input methods.|
754e41f4b71Sopenharmony_ci
755e41f4b71Sopenharmony_ci### onWillDelete<sup>12+</sup>
756e41f4b71Sopenharmony_ci
757e41f4b71Sopenharmony_cionWillDelete(callback: Callback\<DeleteValue, boolean>)
758e41f4b71Sopenharmony_ci
759e41f4b71Sopenharmony_ciInvoked when text is about to be deleted.
760e41f4b71Sopenharmony_ci
761e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
762e41f4b71Sopenharmony_ci
763e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
764e41f4b71Sopenharmony_ci
765e41f4b71Sopenharmony_ci**Parameters**
766e41f4b71Sopenharmony_ci
767e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description              |
768e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------ |
769e41f4b71Sopenharmony_ci| callback  | Callback\<[DeleteValue](ts-text-common.md#deletevalue12), boolean> | Yes  | Callback invoked when text is about to be deleted.<br>It returns **true** if the text is deleted; returns **false** otherwise.<br>This callback is not invoked for text preview.<br>It is available only for system input methods.|
770e41f4b71Sopenharmony_ci
771e41f4b71Sopenharmony_ci### onDidDelete<sup>12+</sup>
772e41f4b71Sopenharmony_ci
773e41f4b71Sopenharmony_cionDidDelete(callback: Callback\<DeleteValue>)
774e41f4b71Sopenharmony_ci
775e41f4b71Sopenharmony_ciCalled when text is deleted.
776e41f4b71Sopenharmony_ci
777e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
778e41f4b71Sopenharmony_ci
779e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
780e41f4b71Sopenharmony_ci
781e41f4b71Sopenharmony_ci**Parameters**
782e41f4b71Sopenharmony_ci
783e41f4b71Sopenharmony_ci| Name| Type                                                        | Mandatory| Description              |
784e41f4b71Sopenharmony_ci| ------ | ------------------------------------------------------------ | ---- | ------------------ |
785e41f4b71Sopenharmony_ci| callback  | Callback\<[DeleteValue](ts-text-common.md#deletevalue12)> | Yes  | Callback invoked when text is deleted.<br>It is available only for system input methods.|
786e41f4b71Sopenharmony_ci
787e41f4b71Sopenharmony_ci## SearchController
788e41f4b71Sopenharmony_ci
789e41f4b71Sopenharmony_ciInherits from [TextContentControllerBase](ts-types.md#textcontentcontrollerbase10).
790e41f4b71Sopenharmony_ci
791e41f4b71Sopenharmony_ci### Objects to Import
792e41f4b71Sopenharmony_ci```
793e41f4b71Sopenharmony_cicontroller: SearchController = new SearchController()
794e41f4b71Sopenharmony_ci```
795e41f4b71Sopenharmony_ci
796e41f4b71Sopenharmony_ci### constructor<sup>8+</sup>
797e41f4b71Sopenharmony_ci
798e41f4b71Sopenharmony_ciconstructor()
799e41f4b71Sopenharmony_ci
800e41f4b71Sopenharmony_ciA constructor used to create a **SearchController** object.
801e41f4b71Sopenharmony_ci
802e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
803e41f4b71Sopenharmony_ci
804e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
805e41f4b71Sopenharmony_ci
806e41f4b71Sopenharmony_ci### caretPosition<sup>8+</sup>
807e41f4b71Sopenharmony_ci
808e41f4b71Sopenharmony_cicaretPosition(value: number): void
809e41f4b71Sopenharmony_ci
810e41f4b71Sopenharmony_ciSets the position of the caret.
811e41f4b71Sopenharmony_ci
812e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
813e41f4b71Sopenharmony_ci
814e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
815e41f4b71Sopenharmony_ci
816e41f4b71Sopenharmony_ci**Parameters**
817e41f4b71Sopenharmony_ci
818e41f4b71Sopenharmony_ci| Name| Type| Mandatory| Description                          |
819e41f4b71Sopenharmony_ci| ------ | -------- | ---- | ---------------------------------- |
820e41f4b71Sopenharmony_ci| value  | number   | Yes  | Length from the start of the character string to the position where the caret is located.|
821e41f4b71Sopenharmony_ci
822e41f4b71Sopenharmony_ci### stopEditing<sup>10+</sup>
823e41f4b71Sopenharmony_ci
824e41f4b71Sopenharmony_cistopEditing(): void
825e41f4b71Sopenharmony_ci
826e41f4b71Sopenharmony_ciExits the editing state.
827e41f4b71Sopenharmony_ci
828e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 11.
829e41f4b71Sopenharmony_ci
830e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
831e41f4b71Sopenharmony_ci
832e41f4b71Sopenharmony_ci### setTextSelection<sup>12+</sup>
833e41f4b71Sopenharmony_ci
834e41f4b71Sopenharmony_cisetTextSelection(selectionStart: number, selectionEnd: number, options?: SelectionOptions): void;
835e41f4b71Sopenharmony_ci
836e41f4b71Sopenharmony_ciSets the text selection range and highlights the selected text when the component is focused. This API works only when the value of **selectionStart** is less than that of **selectionEnd**.
837e41f4b71Sopenharmony_ci
838e41f4b71Sopenharmony_ci**Atomic service API**: This API can be used in atomic services since API version 12.
839e41f4b71Sopenharmony_ci
840e41f4b71Sopenharmony_ci**System capability**: SystemCapability.ArkUI.ArkUI.Full
841e41f4b71Sopenharmony_ci
842e41f4b71Sopenharmony_ci**Parameters**
843e41f4b71Sopenharmony_ci
844e41f4b71Sopenharmony_ci| Name        | Type| Mandatory| Description  |
845e41f4b71Sopenharmony_ci| -------------- | -------- | ---- | -------- |
846e41f4b71Sopenharmony_ci| selectionStart | number   | Yes  | Start position of the text selection range. The start position of text in the text box is 0.<br>A value less than 0 is handled as **0**. A value greater than the maximum text length is handled as the maximum text length.<br>|
847e41f4b71Sopenharmony_ci| selectionEnd   | number   | Yes  | End position of the text selection range.<br>A value less than 0 is handled as the value **0**. A value greater than the maximum text length is handled as the maximum text length.<br>|
848e41f4b71Sopenharmony_ci| options | [SelectionOptions](ts-types.md#selectionoptions12) | No   | Configuration options for text selection.<br>Default value: **MenuPolicy.DEFAULT**|
849e41f4b71Sopenharmony_ci
850e41f4b71Sopenharmony_ci>  **NOTE**
851e41f4b71Sopenharmony_ci>
852e41f4b71Sopenharmony_ci>  If **selectionStart** or **selectionEnd** is set to **undefined**, the value **0** will be used.
853e41f4b71Sopenharmony_ci>
854e41f4b71Sopenharmony_ci>  If **selectionMenuHidden** is set to **true** or a 2-in-1 device is used, calling **setTextSelection** does not display the context menu even when **options** is set to **MenuPolicy.SHOW**.
855e41f4b71Sopenharmony_ci>
856e41f4b71Sopenharmony_ci>  If the selected text contains an emoji, the emoji is selected when its start position is within the text selection range.
857e41f4b71Sopenharmony_ci
858e41f4b71Sopenharmony_ci##  Example
859e41f4b71Sopenharmony_ci
860e41f4b71Sopenharmony_ci### Example 1
861e41f4b71Sopenharmony_ciThis example demonstrates the basic usage of **Search**.
862e41f4b71Sopenharmony_ci```ts
863e41f4b71Sopenharmony_ci// xxx.ets
864e41f4b71Sopenharmony_ci@Entry
865e41f4b71Sopenharmony_ci@Component
866e41f4b71Sopenharmony_cistruct SearchExample {
867e41f4b71Sopenharmony_ci  @State changeValue: string = ''
868e41f4b71Sopenharmony_ci  @State submitValue: string = ''
869e41f4b71Sopenharmony_ci  @State positionInfo: CaretOffset = { index: 0, x: 0, y: 0 }
870e41f4b71Sopenharmony_ci  controller: SearchController = new SearchController()
871e41f4b71Sopenharmony_ci
872e41f4b71Sopenharmony_ci  build() {
873e41f4b71Sopenharmony_ci    Column({space: 10}) {
874e41f4b71Sopenharmony_ci      Text('onSubmit:' + this.submitValue).fontSize(18).margin(15)
875e41f4b71Sopenharmony_ci      Text('onChange:' + this.changeValue).fontSize(18).margin(15)
876e41f4b71Sopenharmony_ci      Search({ value: this.changeValue, placeholder: 'Type to search...', controller: this.controller })
877e41f4b71Sopenharmony_ci        .searchButton('SEARCH')
878e41f4b71Sopenharmony_ci        .width('95%')
879e41f4b71Sopenharmony_ci        .height(40)
880e41f4b71Sopenharmony_ci        .backgroundColor('#F5F5F5')
881e41f4b71Sopenharmony_ci        .placeholderColor(Color.Grey)
882e41f4b71Sopenharmony_ci        .placeholderFont({ size: 14, weight: 400 })
883e41f4b71Sopenharmony_ci        .textFont({ size: 14, weight: 400 })
884e41f4b71Sopenharmony_ci        .onSubmit((value: string) => {
885e41f4b71Sopenharmony_ci          this.submitValue = value
886e41f4b71Sopenharmony_ci        })
887e41f4b71Sopenharmony_ci        .onChange((value: string) => {
888e41f4b71Sopenharmony_ci          this.changeValue = value
889e41f4b71Sopenharmony_ci        })
890e41f4b71Sopenharmony_ci        .margin(20)
891e41f4b71Sopenharmony_ci      Button('Set caretPosition 1')
892e41f4b71Sopenharmony_ci        .onClick(() => {
893e41f4b71Sopenharmony_ci          // Move the caret to after the first entered character.
894e41f4b71Sopenharmony_ci          this.controller.caretPosition(1)
895e41f4b71Sopenharmony_ci        })
896e41f4b71Sopenharmony_ci      Button('Get CaretOffset')
897e41f4b71Sopenharmony_ci        .onClick(() => {
898e41f4b71Sopenharmony_ci          this.positionInfo = this.controller.getCaretOffset()
899e41f4b71Sopenharmony_ci        })
900e41f4b71Sopenharmony_ci    }.width('100%')
901e41f4b71Sopenharmony_ci  }
902e41f4b71Sopenharmony_ci}
903e41f4b71Sopenharmony_ci```
904e41f4b71Sopenharmony_ci
905e41f4b71Sopenharmony_ci![search](figures/search.gif)
906e41f4b71Sopenharmony_ci
907e41f4b71Sopenharmony_ci### Example 2
908e41f4b71Sopenharmony_ciThis example shows how to set the **searchButton**, **searchIcon**, and **cancelButton** attributes.
909e41f4b71Sopenharmony_ci```ts
910e41f4b71Sopenharmony_ci// xxx.ets
911e41f4b71Sopenharmony_ci@Entry
912e41f4b71Sopenharmony_ci@Component
913e41f4b71Sopenharmony_cistruct SearchExample {
914e41f4b71Sopenharmony_ci  @State changeValue: string = ''
915e41f4b71Sopenharmony_ci  @State submitValue: string = ''
916e41f4b71Sopenharmony_ci
917e41f4b71Sopenharmony_ci  build() {
918e41f4b71Sopenharmony_ci    Column() {
919e41f4b71Sopenharmony_ci      Text('onSubmit:' + this.submitValue).fontSize(18).margin(15)
920e41f4b71Sopenharmony_ci      Search({ value: this.changeValue, placeholder: 'Type to search...' })
921e41f4b71Sopenharmony_ci        .searchButton('SEARCH')
922e41f4b71Sopenharmony_ci        .searchIcon({
923e41f4b71Sopenharmony_ci          src: $r('app.media.search')
924e41f4b71Sopenharmony_ci        })
925e41f4b71Sopenharmony_ci        .cancelButton({
926e41f4b71Sopenharmony_ci          style: CancelButtonStyle.CONSTANT,
927e41f4b71Sopenharmony_ci          icon: {
928e41f4b71Sopenharmony_ci            src: $r('app.media.cancel')
929e41f4b71Sopenharmony_ci          }
930e41f4b71Sopenharmony_ci        })
931e41f4b71Sopenharmony_ci        .width('90%')
932e41f4b71Sopenharmony_ci        .height(40)
933e41f4b71Sopenharmony_ci        .maxLength(20)
934e41f4b71Sopenharmony_ci        .backgroundColor('#F5F5F5')
935e41f4b71Sopenharmony_ci        .placeholderColor(Color.Grey)
936e41f4b71Sopenharmony_ci        .placeholderFont({ size: 14, weight: 400 })
937e41f4b71Sopenharmony_ci        .textFont({ size: 14, weight: 400 })
938e41f4b71Sopenharmony_ci        .onSubmit((value: string) => {
939e41f4b71Sopenharmony_ci          this.submitValue = value
940e41f4b71Sopenharmony_ci        })
941e41f4b71Sopenharmony_ci        .onChange((value: string) => {
942e41f4b71Sopenharmony_ci          this.changeValue = value
943e41f4b71Sopenharmony_ci        })
944e41f4b71Sopenharmony_ci        .margin(20)
945e41f4b71Sopenharmony_ci    }.width('100%')
946e41f4b71Sopenharmony_ci  }
947e41f4b71Sopenharmony_ci}
948e41f4b71Sopenharmony_ci```
949e41f4b71Sopenharmony_ci
950e41f4b71Sopenharmony_ci![searchButton](figures/searchButton.gif)
951e41f4b71Sopenharmony_ci
952e41f4b71Sopenharmony_ci
953e41f4b71Sopenharmony_ci### Example 3
954e41f4b71Sopenharmony_ciThis example illustrates how to bind a custom keyboard to the **Search** component.
955e41f4b71Sopenharmony_ci```ts
956e41f4b71Sopenharmony_ci// xxx.ets
957e41f4b71Sopenharmony_ci@Entry
958e41f4b71Sopenharmony_ci@Component
959e41f4b71Sopenharmony_cistruct SearchExample {
960e41f4b71Sopenharmony_ci  controller: SearchController = new SearchController()
961e41f4b71Sopenharmony_ci  @State inputValue: string = ""
962e41f4b71Sopenharmony_ci
963e41f4b71Sopenharmony_ci  // Create a custom keyboard component.
964e41f4b71Sopenharmony_ci  @Builder CustomKeyboardBuilder() {
965e41f4b71Sopenharmony_ci    Column() {
966e41f4b71Sopenharmony_ci      Button('x').onClick(() => {
967e41f4b71Sopenharmony_ci        // Disable the custom keyboard.
968e41f4b71Sopenharmony_ci        this.controller.stopEditing()
969e41f4b71Sopenharmony_ci      })
970e41f4b71Sopenharmony_ci      Grid() {
971e41f4b71Sopenharmony_ci        ForEach([1, 2, 3, 4, 5, 6, 7, 8, 9, '*', 0, '#'], (item: number | string) => {
972e41f4b71Sopenharmony_ci          GridItem() {
973e41f4b71Sopenharmony_ci            Button(item + "")
974e41f4b71Sopenharmony_ci              .width(110).onClick(() => {
975e41f4b71Sopenharmony_ci              this.inputValue += item
976e41f4b71Sopenharmony_ci            })
977e41f4b71Sopenharmony_ci          }
978e41f4b71Sopenharmony_ci        })
979e41f4b71Sopenharmony_ci      }.maxCount(3).columnsGap(10).rowsGap(10).padding(5)
980e41f4b71Sopenharmony_ci    }.backgroundColor(Color.Gray)
981e41f4b71Sopenharmony_ci  }
982e41f4b71Sopenharmony_ci
983e41f4b71Sopenharmony_ci  build() {
984e41f4b71Sopenharmony_ci    Column() {
985e41f4b71Sopenharmony_ci      Search({ controller: this.controller, value: this.inputValue})
986e41f4b71Sopenharmony_ci        // Bind the custom keyboard.
987e41f4b71Sopenharmony_ci        .customKeyboard(this.CustomKeyboardBuilder()).margin(10).border({ width: 1 })
988e41f4b71Sopenharmony_ci    }
989e41f4b71Sopenharmony_ci  }
990e41f4b71Sopenharmony_ci}
991e41f4b71Sopenharmony_ci```
992e41f4b71Sopenharmony_ci
993e41f4b71Sopenharmony_ci![customKeyboard](figures/searchCustomKeyboard.png)
994e41f4b71Sopenharmony_ci
995e41f4b71Sopenharmony_ci### Example 4
996e41f4b71Sopenharmony_ciThis example shows how to set the **enterKeyType** attribute.
997e41f4b71Sopenharmony_ci```ts
998e41f4b71Sopenharmony_ci// xxx.ets
999e41f4b71Sopenharmony_ci@Entry
1000e41f4b71Sopenharmony_ci@Component
1001e41f4b71Sopenharmony_cistruct SearchExample {
1002e41f4b71Sopenharmony_ci  @State Text: string = ''
1003e41f4b71Sopenharmony_ci  @State enterTypes: Array<EnterKeyType> = [EnterKeyType.Go, EnterKeyType.Search, EnterKeyType.Send, EnterKeyType.Done, EnterKeyType.Next, EnterKeyType.PREVIOUS, EnterKeyType.NEW_LINE]
1004e41f4b71Sopenharmony_ci  @State index: number = 0
1005e41f4b71Sopenharmony_ci  build() {
1006e41f4b71Sopenharmony_ci    Column({ space: 20 }) {
1007e41f4b71Sopenharmony_ci      Search({ placeholder: 'Enter text', value: this.Text })
1008e41f4b71Sopenharmony_ci        .width(380)
1009e41f4b71Sopenharmony_ci        .enterKeyType(this.enterTypes[this.index])
1010e41f4b71Sopenharmony_ci        .onChange((value: string) => {
1011e41f4b71Sopenharmony_ci          this.Text = value
1012e41f4b71Sopenharmony_ci        })
1013e41f4b71Sopenharmony_ci        .onSubmit((value: String) => {
1014e41f4b71Sopenharmony_ci          console.log("trigger search onsubmit" + value);
1015e41f4b71Sopenharmony_ci        })
1016e41f4b71Sopenharmony_ci
1017e41f4b71Sopenharmony_ci      Button('Change EnterKeyType').onClick(() => {
1018e41f4b71Sopenharmony_ci        this.index = (this.index + 1) % this.enterTypes.length;
1019e41f4b71Sopenharmony_ci      })
1020e41f4b71Sopenharmony_ci    }.width('100%')
1021e41f4b71Sopenharmony_ci  }
1022e41f4b71Sopenharmony_ci}
1023e41f4b71Sopenharmony_ci```
1024e41f4b71Sopenharmony_ci
1025e41f4b71Sopenharmony_ci![searchEnterKeyType](figures/searchEnterKey.gif)
1026e41f4b71Sopenharmony_ci
1027e41f4b71Sopenharmony_ci### Example 5
1028e41f4b71Sopenharmony_ci
1029e41f4b71Sopenharmony_ciThis example shows how to use the **lineHeight**, **letterSpacing**, and **decoration** attributes.
1030e41f4b71Sopenharmony_ci
1031e41f4b71Sopenharmony_ci```ts
1032e41f4b71Sopenharmony_ci// xxx.ets
1033e41f4b71Sopenharmony_ci@Entry
1034e41f4b71Sopenharmony_ci@Component
1035e41f4b71Sopenharmony_cistruct SearchExample {
1036e41f4b71Sopenharmony_ci  build() {
1037e41f4b71Sopenharmony_ci    Row() {
1038e41f4b71Sopenharmony_ci      Column() {
1039e41f4b71Sopenharmony_ci        Text('lineHeight').fontSize(9).fontColor(0xCCCCCC)
1040e41f4b71Sopenharmony_ci        Search({value: 'lineHeight unset'})
1041e41f4b71Sopenharmony_ci          .border({ width: 1 }).padding(10)
1042e41f4b71Sopenharmony_ci        Search({value: 'lineHeight 15'})
1043e41f4b71Sopenharmony_ci          .border({ width: 1 }).padding(10).lineHeight(15)
1044e41f4b71Sopenharmony_ci        Search({value: 'lineHeight 30'})
1045e41f4b71Sopenharmony_ci          .border({ width: 1 }).padding(10).lineHeight(30)
1046e41f4b71Sopenharmony_ci
1047e41f4b71Sopenharmony_ci        Text('letterSpacing').fontSize(9).fontColor(0xCCCCCC)
1048e41f4b71Sopenharmony_ci        Search({value: 'letterSpacing 0'})
1049e41f4b71Sopenharmony_ci          .border({ width: 1 }).padding(5).letterSpacing(0)
1050e41f4b71Sopenharmony_ci        Search({value: 'letterSpacing 3'})
1051e41f4b71Sopenharmony_ci          .border({ width: 1 }).padding(5).letterSpacing(3)
1052e41f4b71Sopenharmony_ci        Search({value: 'letterSpacing -1'})
1053e41f4b71Sopenharmony_ci          .border({ width: 1 }).padding(5).letterSpacing(-1)
1054e41f4b71Sopenharmony_ci
1055e41f4b71Sopenharmony_ci        Text('decoration').fontSize(9).fontColor(0xCCCCCC)
1056e41f4b71Sopenharmony_ci        Search({value: 'LineThrough, Red'})
1057e41f4b71Sopenharmony_ci          .border({ width: 1 }).padding(5)
1058e41f4b71Sopenharmony_ci          .decoration({type: TextDecorationType.LineThrough, color: Color.Red})
1059e41f4b71Sopenharmony_ci        Search({value: 'Overline, Red, DOTTED'})
1060e41f4b71Sopenharmony_ci          .border({ width: 1 }).padding(5)
1061e41f4b71Sopenharmony_ci          .decoration({type: TextDecorationType.Overline, color: Color.Red, style: TextDecorationStyle.DOTTED})
1062e41f4b71Sopenharmony_ci        Search({value: 'Underline, Red, WAVY'})
1063e41f4b71Sopenharmony_ci          .border({ width: 1 }).padding(5)
1064e41f4b71Sopenharmony_ci          .decoration({type: TextDecorationType.Underline, color: Color.Red, style: TextDecorationStyle.WAVY})
1065e41f4b71Sopenharmony_ci      }.height('90%')
1066e41f4b71Sopenharmony_ci    }
1067e41f4b71Sopenharmony_ci    .width('90%')
1068e41f4b71Sopenharmony_ci    .margin(10)
1069e41f4b71Sopenharmony_ci  }
1070e41f4b71Sopenharmony_ci}
1071e41f4b71Sopenharmony_ci
1072e41f4b71Sopenharmony_ci```
1073e41f4b71Sopenharmony_ci
1074e41f4b71Sopenharmony_ci![SearchDecoration](figures/search_decoration.png)
1075e41f4b71Sopenharmony_ci
1076e41f4b71Sopenharmony_ci### Example 6
1077e41f4b71Sopenharmony_ciThis example shows how to set the **fontFeature** attribute, with a comparison between the ss01-enabled and ss01-disabled effects.
1078e41f4b71Sopenharmony_ci
1079e41f4b71Sopenharmony_ci```ts
1080e41f4b71Sopenharmony_ci@Entry
1081e41f4b71Sopenharmony_ci@Component
1082e41f4b71Sopenharmony_cistruct search {
1083e41f4b71Sopenharmony_ci  @State text1: string = 'This is ss01 on : 0123456789'
1084e41f4b71Sopenharmony_ci  @State text2: string = 'This is ss01 off: 0123456789'
1085e41f4b71Sopenharmony_ci
1086e41f4b71Sopenharmony_ci  build() {
1087e41f4b71Sopenharmony_ci    Column(){
1088e41f4b71Sopenharmony_ci      Search({value: this.text1})
1089e41f4b71Sopenharmony_ci        .margin({top:200})
1090e41f4b71Sopenharmony_ci        .fontFeature("\"ss01\" on")
1091e41f4b71Sopenharmony_ci      Search({value: this.text2})
1092e41f4b71Sopenharmony_ci        .margin({top:10})
1093e41f4b71Sopenharmony_ci        .fontFeature("\"ss01\" off")
1094e41f4b71Sopenharmony_ci    }
1095e41f4b71Sopenharmony_ci    .width("90%")
1096e41f4b71Sopenharmony_ci    .margin("5%")
1097e41f4b71Sopenharmony_ci  }
1098e41f4b71Sopenharmony_ci}
1099e41f4b71Sopenharmony_ci```
1100e41f4b71Sopenharmony_ci![fontFeature](figures/searchFontFeature.png)
1101e41f4b71Sopenharmony_ci
1102e41f4b71Sopenharmony_ci### Example 7
1103e41f4b71Sopenharmony_ci
1104e41f4b71Sopenharmony_ciThis example shows how to support custom keyboard avoidance.
1105e41f4b71Sopenharmony_ci
1106e41f4b71Sopenharmony_ci```ts
1107e41f4b71Sopenharmony_ci@Entry
1108e41f4b71Sopenharmony_ci@Component
1109e41f4b71Sopenharmony_cistruct SearchExample {
1110e41f4b71Sopenharmony_ci  controller: SearchController = new SearchController()
1111e41f4b71Sopenharmony_ci  @State inputValue: string = ""
1112e41f4b71Sopenharmony_ci  @State height1:string|number = '80%'
1113e41f4b71Sopenharmony_ci  @State supportAvoidance:boolean = true;
1114e41f4b71Sopenharmony_ci  // Create a custom keyboard component.
1115e41f4b71Sopenharmony_ci  @Builder CustomKeyboardBuilder() {
1116e41f4b71Sopenharmony_ci    Column() {
1117e41f4b71Sopenharmony_ci      Row(){
1118e41f4b71Sopenharmony_ci        Button('x').onClick(() => {
1119e41f4b71Sopenharmony_ci          // Disable the custom keyboard.
1120e41f4b71Sopenharmony_ci          this.controller.stopEditing()
1121e41f4b71Sopenharmony_ci        }).margin(10)
1122e41f4b71Sopenharmony_ci      }
1123e41f4b71Sopenharmony_ci      Grid() {
1124e41f4b71Sopenharmony_ci        ForEach([1, 2, 3, 4, 5, 6, 7, 8, 9, '*', 0, '#'], (item: number | string) => {
1125e41f4b71Sopenharmony_ci          GridItem() {
1126e41f4b71Sopenharmony_ci            Button(item + "")
1127e41f4b71Sopenharmony_ci              .width(110).onClick(() => {
1128e41f4b71Sopenharmony_ci              this.inputValue += item
1129e41f4b71Sopenharmony_ci            })
1130e41f4b71Sopenharmony_ci          }
1131e41f4b71Sopenharmony_ci        })
1132e41f4b71Sopenharmony_ci      }.maxCount(3).columnsGap(10).rowsGap(10).padding(5)
1133e41f4b71Sopenharmony_ci    }
1134e41f4b71Sopenharmony_ci    .backgroundColor(Color.Gray)
1135e41f4b71Sopenharmony_ci  }
1136e41f4b71Sopenharmony_ci
1137e41f4b71Sopenharmony_ci  build() {
1138e41f4b71Sopenharmony_ci    Column() {
1139e41f4b71Sopenharmony_ci      Row(){
1140e41f4b71Sopenharmony_ci        Button("20%")
1141e41f4b71Sopenharmony_ci          .fontSize(24)
1142e41f4b71Sopenharmony_ci          .onClick(()=>{
1143e41f4b71Sopenharmony_ci            this.height1 = "20%"
1144e41f4b71Sopenharmony_ci          })
1145e41f4b71Sopenharmony_ci        Button("80%")
1146e41f4b71Sopenharmony_ci          .fontSize(24)
1147e41f4b71Sopenharmony_ci          .margin({left:20})
1148e41f4b71Sopenharmony_ci          .onClick(()=>{
1149e41f4b71Sopenharmony_ci            this.height1 = "80%"
1150e41f4b71Sopenharmony_ci          })
1151e41f4b71Sopenharmony_ci      }
1152e41f4b71Sopenharmony_ci      .justifyContent(FlexAlign.Center)
1153e41f4b71Sopenharmony_ci      .alignItems(VerticalAlign.Bottom)
1154e41f4b71Sopenharmony_ci      .height(this.height1)
1155e41f4b71Sopenharmony_ci      .width("100%")
1156e41f4b71Sopenharmony_ci      .padding({bottom:50})
1157e41f4b71Sopenharmony_ci      Search({ controller: this.controller, value: this.inputValue})
1158e41f4b71Sopenharmony_ci        // Bind the custom keyboard.
1159e41f4b71Sopenharmony_ci        .customKeyboard(this.CustomKeyboardBuilder(),{ supportAvoidance: this.supportAvoidance }).margin(10).border({ width: 1 })
1160e41f4b71Sopenharmony_ci    }
1161e41f4b71Sopenharmony_ci  }
1162e41f4b71Sopenharmony_ci}
1163e41f4b71Sopenharmony_ci```
1164e41f4b71Sopenharmony_ci
1165e41f4b71Sopenharmony_ci![CustomSearchKeyType](figures/searchCustomKeyboard.gif)
1166e41f4b71Sopenharmony_ci
1167e41f4b71Sopenharmony_ci### Example 8
1168e41f4b71Sopenharmony_ci
1169e41f4b71Sopenharmony_ciThis example shows how to set **minFontSize** and **maxFontSize**.
1170e41f4b71Sopenharmony_ci
1171e41f4b71Sopenharmony_ci```ts
1172e41f4b71Sopenharmony_ci// xxx.ets
1173e41f4b71Sopenharmony_ci@Entry
1174e41f4b71Sopenharmony_ci@Component
1175e41f4b71Sopenharmony_cistruct SearchExample {
1176e41f4b71Sopenharmony_ci  build() {
1177e41f4b71Sopenharmony_ci    Row() {
1178e41f4b71Sopenharmony_ci      Column() {
1179e41f4b71Sopenharmony_ci        Text('adaptive font').fontSize(9).fontColor(0xCCCCCC)
1180e41f4b71Sopenharmony_ci
1181e41f4b71Sopenharmony_ci        Search({value: 'This is the text without the adaptive font'})
1182e41f4b71Sopenharmony_ci          .width('80%').height(90).borderWidth(1)
1183e41f4b71Sopenharmony_ci        Search({value: 'This is the text without the adaptive font'})
1184e41f4b71Sopenharmony_ci          .width('80%').height(90).borderWidth(1)
1185e41f4b71Sopenharmony_ci          .minFontSize(4)
1186e41f4b71Sopenharmony_ci          .maxFontSize(40)
1187e41f4b71Sopenharmony_ci      }.height('90%')
1188e41f4b71Sopenharmony_ci    }
1189e41f4b71Sopenharmony_ci    .width('90%')
1190e41f4b71Sopenharmony_ci    .margin(10)
1191e41f4b71Sopenharmony_ci  }
1192e41f4b71Sopenharmony_ci}
1193e41f4b71Sopenharmony_ci```
1194e41f4b71Sopenharmony_ci
1195e41f4b71Sopenharmony_ci![searchAdaptFont](figures/search_adapt_font.png)
1196e41f4b71Sopenharmony_ci
1197e41f4b71Sopenharmony_ci### Example 9
1198e41f4b71Sopenharmony_ci
1199e41f4b71Sopenharmony_ciThis example shows how to use the insert and delete callbacks.
1200e41f4b71Sopenharmony_ci
1201e41f4b71Sopenharmony_ci```ts
1202e41f4b71Sopenharmony_ci// xxx.ets
1203e41f4b71Sopenharmony_ci@Entry
1204e41f4b71Sopenharmony_ci@Component
1205e41f4b71Sopenharmony_cistruct SearchExample {
1206e41f4b71Sopenharmony_ci  @State insertValue: string = ""
1207e41f4b71Sopenharmony_ci  @State deleteValue: string = ""
1208e41f4b71Sopenharmony_ci  @State insertOffset: number = 0
1209e41f4b71Sopenharmony_ci  @State deleteOffset: number = 0
1210e41f4b71Sopenharmony_ci  @State deleteDirection: number = 0
1211e41f4b71Sopenharmony_ci
1212e41f4b71Sopenharmony_ci  build() {
1213e41f4b71Sopenharmony_ci    Row() {
1214e41f4b71Sopenharmony_ci      Column() {
1215e41f4b71Sopenharmony_ci        Search({ value: "Insert callbacks are supported" })
1216e41f4b71Sopenharmony_ci          .height(60)
1217e41f4b71Sopenharmony_ci          .onWillInsert((info: InsertValue) => {
1218e41f4b71Sopenharmony_ci            this.insertValue = info.insertValue
1219e41f4b71Sopenharmony_ci            return true;
1220e41f4b71Sopenharmony_ci          })
1221e41f4b71Sopenharmony_ci          .onDidInsert((info: InsertValue) => {
1222e41f4b71Sopenharmony_ci            this.insertOffset = info.insertOffset
1223e41f4b71Sopenharmony_ci          })
1224e41f4b71Sopenharmony_ci
1225e41f4b71Sopenharmony_ci        Text("insertValue:" + this.insertValue + "  insertOffset:" + this.insertOffset).height(30)
1226e41f4b71Sopenharmony_ci
1227e41f4b71Sopenharmony_ci        Search({ value: "Delete callbacks are supported" })
1228e41f4b71Sopenharmony_ci          .height(60)
1229e41f4b71Sopenharmony_ci          .onWillDelete((info: DeleteValue) => {
1230e41f4b71Sopenharmony_ci            this.deleteValue = info.deleteValue
1231e41f4b71Sopenharmony_ci            info.direction
1232e41f4b71Sopenharmony_ci            return true;
1233e41f4b71Sopenharmony_ci          })
1234e41f4b71Sopenharmony_ci          .onDidDelete((info: DeleteValue) => {
1235e41f4b71Sopenharmony_ci            this.deleteOffset = info.deleteOffset
1236e41f4b71Sopenharmony_ci            this.deleteDirection = info.direction
1237e41f4b71Sopenharmony_ci          })
1238e41f4b71Sopenharmony_ci
1239e41f4b71Sopenharmony_ci        Text("deleteValue:" + this.deleteValue + "  deleteOffset:" + this.deleteOffset).height(30)
1240e41f4b71Sopenharmony_ci        Text("deleteDirection:" + (this.deleteDirection == 0 ? "BACKWARD" : "FORWARD")).height(30)
1241e41f4b71Sopenharmony_ci
1242e41f4b71Sopenharmony_ci      }.width('100%')
1243e41f4b71Sopenharmony_ci    }
1244e41f4b71Sopenharmony_ci    .height('100%')
1245e41f4b71Sopenharmony_ci  }
1246e41f4b71Sopenharmony_ci}
1247e41f4b71Sopenharmony_ci```
1248e41f4b71Sopenharmony_ci
1249e41f4b71Sopenharmony_ci![SearchInsertAndDelete](figures/SearchInsertAndDelete.PNG)
1250e41f4b71Sopenharmony_ci
1251e41f4b71Sopenharmony_ci### Example 10
1252e41f4b71Sopenharmony_ci
1253e41f4b71Sopenharmony_ciThis example shows how to set **editMenuOptions**.
1254e41f4b71Sopenharmony_ci
1255e41f4b71Sopenharmony_ci```ts
1256e41f4b71Sopenharmony_ci// xxx.ets
1257e41f4b71Sopenharmony_ci@Entry
1258e41f4b71Sopenharmony_ci@Component
1259e41f4b71Sopenharmony_cistruct Index {
1260e41f4b71Sopenharmony_ci  @State text: string = 'Search editMenuOptions'
1261e41f4b71Sopenharmony_ci
1262e41f4b71Sopenharmony_ci  onCreateMenu(menuItems: Array<TextMenuItem>) {
1263e41f4b71Sopenharmony_ci    menuItems.forEach((value, index) => {
1264e41f4b71Sopenharmony_ci      value.icon = $r('app.media.startIcon')
1265e41f4b71Sopenharmony_ci      if (value.id.equals(TextMenuItemId.COPY)) {
1266e41f4b71Sopenharmony_ci        value.content = "Copy_custom"
1267e41f4b71Sopenharmony_ci      }
1268e41f4b71Sopenharmony_ci      if (value.id.equals(TextMenuItemId.SELECT_ALL)) {
1269e41f4b71Sopenharmony_ci        value.content = "Select all_custom"
1270e41f4b71Sopenharmony_ci      }
1271e41f4b71Sopenharmony_ci    })
1272e41f4b71Sopenharmony_ci    let item1: TextMenuItem = {
1273e41f4b71Sopenharmony_ci      content: 'custom1',
1274e41f4b71Sopenharmony_ci      icon: $r('app.media.startIcon'),
1275e41f4b71Sopenharmony_ci      id: TextMenuItemId.of('custom1'),
1276e41f4b71Sopenharmony_ci    }
1277e41f4b71Sopenharmony_ci    let item2: TextMenuItem = {
1278e41f4b71Sopenharmony_ci      content: 'custom2',
1279e41f4b71Sopenharmony_ci      id: TextMenuItemId.of('custom2'),
1280e41f4b71Sopenharmony_ci      icon: $r('app.media.startIcon'),
1281e41f4b71Sopenharmony_ci    }
1282e41f4b71Sopenharmony_ci    menuItems.push(item1)
1283e41f4b71Sopenharmony_ci    menuItems.unshift(item2)
1284e41f4b71Sopenharmony_ci    return menuItems
1285e41f4b71Sopenharmony_ci  }
1286e41f4b71Sopenharmony_ci
1287e41f4b71Sopenharmony_ci  build() {
1288e41f4b71Sopenharmony_ci    Column() {
1289e41f4b71Sopenharmony_ci      Search({ value: this.text })
1290e41f4b71Sopenharmony_ci        .width('95%')
1291e41f4b71Sopenharmony_ci        .editMenuOptions({
1292e41f4b71Sopenharmony_ci          onCreateMenu: this.onCreateMenu, onMenuItemClick: (menuItem: TextMenuItem, textRange: TextRange) => {
1293e41f4b71Sopenharmony_ci            if (menuItem.id.equals(TextMenuItemId.of("custom2"))) {
1294e41f4b71Sopenharmony_ci              console.log("Intercept id: custom2 start:" + textRange.start + "; end:" + textRange.end)
1295e41f4b71Sopenharmony_ci              return true;
1296e41f4b71Sopenharmony_ci            }
1297e41f4b71Sopenharmony_ci            if (menuItem.id.equals(TextMenuItemId.COPY)) {
1298e41f4b71Sopenharmony_ci              console.log("Intercept COPY start:" + textRange.start + "; end:" + textRange.end)
1299e41f4b71Sopenharmony_ci              return true;
1300e41f4b71Sopenharmony_ci            }
1301e41f4b71Sopenharmony_ci            if (menuItem.id.equals(TextMenuItemId.SELECT_ALL)) {
1302e41f4b71Sopenharmony_ci              console.log("Do not intercept SELECT_ALL start:" + textRange.start + "; end:" + textRange.end)
1303e41f4b71Sopenharmony_ci              return false;
1304e41f4b71Sopenharmony_ci            }
1305e41f4b71Sopenharmony_ci            return false;
1306e41f4b71Sopenharmony_ci          }
1307e41f4b71Sopenharmony_ci        })
1308e41f4b71Sopenharmony_ci        .margin({ top: 100 })
1309e41f4b71Sopenharmony_ci    }
1310e41f4b71Sopenharmony_ci    .width("90%")
1311e41f4b71Sopenharmony_ci    .margin("5%")
1312e41f4b71Sopenharmony_ci  }
1313e41f4b71Sopenharmony_ci}
1314e41f4b71Sopenharmony_ci```
1315e41f4b71Sopenharmony_ci
1316e41f4b71Sopenharmony_ci![searchEditMenuOptions](figures/searchEditMenuOptions.gif)
1317