The initial APIs of this module are supported since API version 10. Newly added APIs will be marked with a superscript to indicate their earliest API version.
The APIs of this module can be used only in the stage model.
The common APIs of text components provide basic text processing capabilities, including caret style settings, layout management, text selection control, and menu item customization. This module is suitable for scenarios that require fine-grained control over text components, such as text editors, rich text apps, and input forms. With these APIs, developers can customize the caret style, obtain text layout information, handle text selection, customize the editing menu, and so on, thereby improving the text interaction experience of the app.
Atomic service API: This API can be used in atomic services since API version 11.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| width | Length | No | Yes | Cursor size. Percentage is not supported. Default value: '2vp' |
| color | ResourceColor | No | Yes | Cursor color. Default value: '#ff007dff', which indicates blue. |
Implements a layout manager object.
After the text content is changed, you must wait for the layout to be completed before you can obtain the most up-to-date layout information.
Take the Text component as an example. For a complete example, see Example 10: Obtaining Text Information of the Text component.
controller: TextController = new TextController(); let layoutManager: LayoutManager = this.controller.getLayoutManager();
getLineCount(): number
Obtains the total number of lines in the component.
After the text content changes, wait until the layout is complete before obtaining the latest total number of lines.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Return value
| Type | Description |
|---|---|
| number | Total number of lines of the component content. Returns 0 when LayoutManager is not bound to the component. |
getGlyphPositionAtCoordinate(x: number, y: number): PositionWithAffinity
Obtains the position information of the character close to the given coordinate.
This API actually obtains the UTF-16 character offset, rather than the glyph offset.
After the text content changes, wait until the layout is complete before obtaining the latest position information.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| x | number | Yes | Horizontal coordinate relative to the component. Unit: px |
| y | number | Yes | Vertical coordinate relative to the component. Unit: px |
Return value
| Type | Description |
|---|---|
| PositionWithAffinity | Character position information. Returns an invalid value when LayoutManager is not bound to the component. |
getCharacterPositionAtCoordinate(x: number, y: number): PositionWithAffinity | undefined
Obtains the position information of the character closest to the specified coordinate.
After the text content changes, wait until the layout is complete before obtaining the latest position information.
The character position returned by this API is the UTF-8 encoding offset.
Atomic service API: This API can be used in atomic services since API version 24.
System capability: SystemCapability.ArkUI.ArkUI.Full
Model restriction: This API can be used only in the stage model.
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| x | number | Yes | Horizontal coordinate relative to the component. Unit: px |
| y | number | Yes | Vertical coordinate relative to the component. Unit: px |
Return value
| Type | Description |
|---|---|
| PositionWithAffinity | undefined | Position information of the character. If LayoutManager is not bound to the component, this API returns undefined. |
getCharacterPositionAtCoordinate(x: number, y: number, encoding?: TextEncoding): PositionWithAffinity | undefined
Obtains the position information of the character closest to the specified coordinate based on the specified encoding type.
After the text content changes, wait until the layout is complete before obtaining the latest position information.
Since: 26.0.0
Atomic service API: This API can be used in atomic services since API version 26.0.0.
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| x | number | Yes | Horizontal coordinate relative to the component. Unit: px |
| y | number | Yes | Vertical coordinate relative to the component. Unit: px |
| encoding | TextEncoding | No | Encoding type used for the character position. In UTF-8 encoding, the character position is in bytes; in UTF-16 encoding, the character position is in UTF-16 code units. Default value: TextEncoding.TEXT_ENCODING_UTF8 |
Return value
| Type | Description |
|---|---|
| PositionWithAffinity | undefined | Character position. Returns undefined when LayoutManager is not bound to a component. |
getGlyphRangeForCharacterRange(charRange: TextRange): Array<TextRange> | undefined
Obtains the glyph range and the actual character range based on the specified text character range. The character offset of this API is UTF-8 encoding.
After the text content changes, wait until the layout is complete before obtaining the latest glyph range information.
Take the text "世界Hello" as an example. The correspondence between the glyph index and the character index under UTF-8 encoding is as follows:
| Text | 世 | 界 | H | e | l | l | o |
|---|---|---|---|---|---|---|---|
| Glyph index range | [0, 1] | [1, 2] | [2, 3] | [3, 4] | [4, 5] | [5, 6] | [6, 7] |
| Character index range (UTF-8) | [0, 3] | [3, 6] | [6, 7] | [7, 8] | [8, 9] | [9, 10] | [10, 11] |
The glyph index range of the character "世" is [0, 1]. Since a Chinese character occupies 3 bytes, its corresponding character index range is [0, 3]. If the specified character index range is [0, 1], it is impossible to parse one-third of a Chinese character, so the actual character index range is [0, 3].
Atomic service API: This API can be used in atomic services since API version 24.
System capability: SystemCapability.ArkUI.ArkUI.Full
Model restriction: This API can be used only in the stage model.
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| charRange | TextRange | Yes | Character range of the text. |
Return value
| Type | Description |
|---|---|
| Array<TextRange> | undefined | The array contains two elements. The first element is the glyph range, and the second element is the actual character range. If the returned range is an abnormal value, the elements in the range are -1. If LayoutManager is not bound to the component, this API returns undefined. |
getGlyphRangeForCharacterRange(charRange: TextRange, encoding?: TextEncoding): Array<TextRange> | undefined
Obtains the glyph range and the actual character range based on the specified encoding type and text character range.
After the text content changes, wait until the layout is complete before obtaining the latest glyph range information.
Take the text "世界Hello" as an example. The correspondence between the glyph index and the character index under different encoding types is as follows:
| Text | 世 | 界 | H | e | l | l | o |
|---|---|---|---|---|---|---|---|
| Glyph index range | [0, 1] | [1, 2] | [2, 3] | [3, 4] | [4, 5] | [5, 6] | [6, 7] |
| Character index range (UTF-8) | [0, 3] | [3, 6] | [6, 7] | [7, 8] | [8, 9] | [9, 10] | [10, 11] |
| Character index range (UTF-16) | [0, 1] | [1, 2] | [2, 3] | [3, 4] | [4, 5] | [5, 6] | [6, 7] |
Under UTF-8 encoding, a Chinese character occupies 3 bytes. The glyph index range of "世" is [0, 1], and its corresponding character index range is [0, 3]. If the specified character index range is [0, 1], it is impossible to parse one-third of a Chinese character, so the actual character index range is [0, 3].
Under UTF-16 encoding, the character index is measured in UTF-16 code units. A BMP character (such as "世") occupies 1 code unit (2 bytes), and a supplementary plane character (such as an emoji) occupies 2 code units (a 4-byte surrogate pair). The glyph index range of "世" is [0, 1], and its corresponding character index range is [0, 1].
Since: 26.0.0
Atomic service API: This API can be used in atomic services since API version 26.0.0.
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| charRange | TextRange | Yes | Character range of the text. |
| encoding | TextEncoding | No | Encoding type used by the character range. Under UTF-8 encoding, the character index is measured in bytes; under UTF-16 encoding, the character index is measured in UTF-16 code units. Default value: TextEncoding.TEXT_ENCODING_UTF8 |
Return value
| Type | Description |
|---|---|
| Array<TextRange> | undefined | The array contains two elements. The first element is the glyph range, and the second is the actual character range. When the returned range is an abnormal value, the elements in the range are -1. When LayoutManager is not bound to a component, this API returns undefined. |
getCharacterRangeForGlyphRange(glyphRange: TextRange): Array<TextRange> | undefined
Obtains the character range and the actual glyph range based on the specified text glyph range. The character offset of this API is UTF-8 encoding.
After the text content changes, wait until the layout is complete before obtaining the latest character range information.
Take the text "世界Hello" as an example. The correspondence between the glyph index and the character index under UTF-8 encoding is as follows:
| Text | 世 | 界 | H | e | l | l | o |
|---|---|---|---|---|---|---|---|
| Glyph index range | [0, 1] | [1, 2] | [2, 3] | [3, 4] | [4, 5] | [5, 6] | [6, 7] |
| Character index range (UTF-8) | [0, 3] | [3, 6] | [6, 7] | [7, 8] | [8, 9] | [9, 10] | [10, 11] |
Its glyph index range is [0, 7]. Since a Chinese character occupies 3 bytes, its corresponding character index range is [0, 11]. If the specified glyph index range is [0, 11], but there are only 7 glyphs in total, the actual glyph index range is [0, 7].
Atomic service API: This API can be used in atomic services since API version 24.
System capability: SystemCapability.ArkUI.ArkUI.Full
Model restriction: This API can be used only in the stage model.
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| glyphRange | TextRange | Yes | Glyph range of the text. |
Return value
| Type | Description |
|---|---|
| Array<TextRange> | undefined | The array contains two elements. The first element is the character range, and the second element is the actual glyph range. If the returned range is an abnormal value, the elements in the range are -1. If LayoutManager is not bound to the component, this API returns undefined. |
getCharacterRangeForGlyphRange(glyphRange: TextRange, encoding?: TextEncoding): Array<TextRange> | undefined
Obtains the character range and the actual glyph range based on the specified encoding type and text glyph range.
After the text content changes, wait until the layout is complete before obtaining the latest character range information.
Take the text "世界Hello" as an example. The correspondence between the glyph index and the character index under different encoding types is as follows:
| Text | 世 | 界 | H | e | l | l | o |
|---|---|---|---|---|---|---|---|
| Glyph index range | [0, 1] | [1, 2] | [2, 3] | [3, 4] | [4, 5] | [5, 6] | [6, 7] |
| Character index range (UTF-8) | [0, 3] | [3, 6] | [6, 7] | [7, 8] | [8, 9] | [9, 10] | [10, 11] |
| Character index range (UTF-16) | [0, 1] | [1, 2] | [2, 3] | [3, 4] | [4, 5] | [5, 6] | [6, 7] |
Under UTF-8 encoding, its glyph index range is [0, 7]. Since a Chinese character occupies 3 bytes, the corresponding character index range is [0, 11]. If the specified glyph index range exceeds the actual number of glyphs (for example, [0, 11]), since there are only 7 glyphs in total, the returned actual glyph index range is [0, 7].
Under UTF-16 encoding, the character index is measured in UTF-16 code units. A BMP character (such as "世") occupies 1 code unit (2 bytes), and a supplementary plane character (such as an emoji) occupies 2 code units (a 4-byte surrogate pair). Its glyph index range is [0, 7], and the corresponding character index range is [0, 7]. If the specified glyph index range exceeds the actual number of glyphs (for example, [0, 10]), since there are only 7 glyphs in total, the returned actual glyph index range is [0, 7].
Since: 26.0.0
Atomic service API: This API can be used in atomic services since API version 26.0.0.
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| glyphRange | TextRange | Yes | Glyph range of the text. |
| encoding | TextEncoding | No | Encoding type used by the character range. Under UTF-8 encoding, the character index is measured in bytes; under UTF-16 encoding, the character index is measured in UTF-16 code units. Default value: TextEncoding.TEXT_ENCODING_UTF8 |
Return value
| Type | Description |
|---|---|
| Array<TextRange> | undefined | The array contains two elements. The first element is the character range, and the second element is the actual glyph range. When the returned range is an abnormal value, the elements in the range are -1. When LayoutManager is not bound to the component, this API returns undefined. |
getLineMetrics(lineNumber: number): LineMetrics
Obtains the information about the specified line, including line metrics, text style information, and font properties.
After the text content changes, wait until the layout is complete before obtaining the latest line information.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| lineNumber | number | Yes | Line number, with a value range of [0, actual line count - 1], starting from 0. When the line number is less than 0 or exceeds the actual line count, an invalid value is returned. |
Return value
| Type | Description |
|---|---|
| LineMetrics | Line information, text style information, and font attribute information. When the line number is less than 0 or exceeds the actual line, returns invalid. When LayoutManager is not bound to the component, returns invalid. |
getRectsForRange(range: TextRange, widthStyle: RectWidthStyle, heightStyle: RectHeightStyle): Array<TextBox>
Obtains the drawing area information of the characters or placeholders within any range of the text, based on the specified rectangle width and height styles.
After the text content changes, wait until the layout is complete before obtaining the latest drawing area information.
The TextRange of the range parameter is a UTF-16 character offset.
Atomic service API: This API can be used in atomic services since API version 14.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| range | TextRange | Yes | Text range of the area to be obtained. |
| widthStyle | RectWidthStyle | Yes | Width specification of the returned rectangular area, used to control how the width of the returned rectangle is calculated. Different specification values affect the width boundary of the rectangle. |
| heightStyle | RectHeightStyle | Yes | Height specification of the returned rectangular area, used to control how the height of the returned rectangle is calculated. Different specification values affect the height boundary of the rectangle. |
Return value
| Type | Description |
|---|---|
| Array<TextBox> | Array of rectangular areas. If LayoutManager is not bound to the component, an empty array is returned. |
Describes the position and affinity of a glyph.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| position | number | No | No | Index of the glyph or character to the component. The value is an integer. |
| affinity | Affinity | No | No | Position affinity, which indicates the tendency of the cursor position at glyph boundaries. For details, see the Affinity enum. |
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| CUT | TextMenuItemId | Yes | No | Default cut, a level-1 menu item. Atomic service API: This API can be used in atomic services since API version 12. |
| COPY | TextMenuItemId | Yes | No | Default copy, a level-1 menu item. Atomic service API: This API can be used in atomic services since API version 12. |
| PASTE | TextMenuItemId | Yes | No | Default paste, a level-1 menu item. Atomic service API: This API can be used in atomic services since API version 12. |
| SELECT_ALL | TextMenuItemId | Yes | No | Default select all, a level-1 menu item. Atomic service API: This API can be used in atomic services since API version 12. |
| COLLABORATION_SERVICE | TextMenuItemId | Yes | No | Collaboration service, a level-1 menu item. Atomic service API: This API can be used in atomic services since API version 12. |
| CAMERA_INPUT | TextMenuItemId | Yes | No | Camera input, a level-1 menu item. Atomic service API: This API can be used in atomic services since API version 12. |
| AI_WRITER13+ | TextMenuItemId | Yes | No | Can polish, summarize, and format the selected text. It is a level-1 menu item. This menu item depends on the large model capability; otherwise, it does not take effect. Atomic service API: This API can be used in atomic services since API version 13. |
| TRANSLATE15+ | TextMenuItemId | Yes | No | Translate, a level-1 menu item. Provides a translation service for the selected text. Atomic service API: This API can be used in atomic services since API version 15. |
| SHARE18+ | TextMenuItemId | Yes | No | Share, a level-1 menu item. Provides a sharing service for the selected text and opens the sharing window to share the selected text content. Atomic service API: This API can be used in atomic services since API version 18. |
| SEARCH18+ | TextMenuItemId | Yes | No | Search, a level-1 menu item. Provides a search service for the selected text and opens the browser to search for the selected text content. Atomic service API: This API can be used in atomic services since API version 18. |
| url20+ | TextMenuItemId | Yes | No | Open link, a level-1 menu item. Provides a jump service for the selected URL and opens the browser search or an app page. Atomic service API: This API can be used in atomic services since API version 20. |
| email20+ | TextMenuItemId | Yes | No | New email, a level-1 menu item. Provides a jump service for the selected email address and opens the email app. Atomic service API: This API can be used in atomic services since API version 20. |
| phoneNumber20+ | TextMenuItemId | Yes | No | Call, a level-1 menu item. Provides a jump service for the selected phone number and opens the dialing page. Atomic service API: This API can be used in atomic services since API version 20. |
| address20+ | TextMenuItemId | Yes | No | Navigate, a level-1 menu item. Provides a jump service for the selected address and opens the map app. Atomic service API: This API can be used in atomic services since API version 20. |
| dateTime20+ | TextMenuItemId | Yes | No | New schedule, a level-1 menu item. Provides a jump service for the selected date and time and opens the new schedule page. Atomic service API: This API can be used in atomic services since API version 20. |
| askAI20+ | TextMenuItemId | Yes | No | Provides AI query capability for the selected text. It is a level-1 menu item. This menu item depends on the large model capability; otherwise, it does not take effect. Atomic service API: This API can be used in atomic services since API version 20. |
| autoFill23+ | TextMenuItemId | Yes | No | Auto fill, a level-1 menu item. After it is tapped, the level-2 menu item "Password Vault" is expanded. It is supported only by Search, TextInput, TextArea, or RichEditor. Atomic service API: This API can be used in atomic services since API version 23. |
| passwordVault23+ | TextMenuItemId | Yes | No | Password Vault, a level-2 menu item. After this menu item is tapped, the Password Vault app is opened. This app provides the capability of auto-filling account names and passwords. It is supported only by Search, TextInput, TextArea, or RichEditor. Atomic service API: This API can be used in atomic services since API version 23. Model restriction: This API can be used only in the stage model. |
static of(id: ResourceStr): TextMenuItemId
Creates a TextMenuItemId object based on id.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| id | ResourceStr | Yes | Identifier of the menu item, used to create a TextMenuItemId object to identify the menu option. |
Return value
| Type | Description |
|---|---|
| TextMenuItemId | Identifier object of a menu item created based on the passed-in ID, used to identify the menu option. |
equals(id: TextMenuItemId): boolean
Checks whether this TextMenuItemId object is the same as another TextMenuItemId object.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| id | TextMenuItemId | Yes | TextMenuItemId object to be compared. |
Return value
| Type | Description |
|---|---|
| boolean | Whether two TextMenuItemId values are equal. The value true indicates that they are equal, and false indicates that they are not equal. |
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| onPrepareMenu20+ | OnPrepareMenuCallback | No | Yes | Triggered before the menu is displayed after the text selection area changes. You can set menu data in this callback. Similar to onCreateMenu but with a different trigger timing: onCreateMenu is triggered when the menu is created and is suitable for initializing menu items; this API is triggered after each selection area change and before the menu is displayed, and is suitable for dynamically adjusting the menu based on the selected content. The two can be used together. Atomic service API: This API can be used in atomic services since API version 20. |
Defines the text range.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| start | number | No | Yes | Start index, starting from 0. |
| end | number | No | Yes | End index, starting from 0. |
type EditableTextOnChangeCallback = (value: string, previewText?: PreviewText, options?: TextChangeOptions) => void
Represents the callback triggered when the content in the text box changes.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| value | string | Yes | Text displayed in the text box. |
| previewText | PreviewText | No | Information about the preview text, including its start position and text content. |
| options15+ | TextChangeOptions | No | Information about the text change, including the selection range, text displayed in the text box, and preview text. |
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Value | Description |
|---|---|---|
| PHONE_NUMBER | 0 | Phone number. |
| URL | 1 | URL. |
| 2 | Email address. | |
| ADDRESS | 3 | Address. |
| DATE_TIME12+ | 4 | Date and time. |
Defines the direction for deleting text.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Value | Description |
|---|---|---|
| BACKWARD | 0 | Backward delete. |
| FORWARD | 1 | Forward delete. |
Enumerates the text superscript and subscript styles.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Value | Description |
|---|---|---|
| NORMAL | 0 | Normal text style. |
| SUPERSCRIPT | 1 | Superscript text style. |
| SUBSCRIPT | 2 | Subscript text style. |
Enumerates the appearance modes of the keyboard.
Atomic service API: This API can be used in atomic services since API version 15.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Value | Description |
|---|---|---|
| NONE_IMMERSIVE | 0 | Default appearance mode, not using immersive style. |
| IMMERSIVE | 1 | Immersive mode, following the system. |
| LIGHT_IMMERSIVE | 2 | Immersive style in light mode. |
| DARK_IMMERSIVE | 3 | Immersive style in dark mode. |
Incremental update policy for text rendering.
Since: 26.0.0
Atomic service API: This API can be used in atomic services since API version 26.0.0.
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Value | Description |
|---|---|---|
| NONE | 0 | Incremental update is disabled, and full layout rendering is used. |
| PARAGRAPH_CACHE | 1 | Incremental update is enabled, and paragraph-level cache is used. This policy takes effect only when the attributed string object bound to the text remains unchanged. If the attributed string object changes, the cache cannot be hit. |
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| insertOffset | number | No | No | Position index of the inserted value, starting from 0. |
| insertValue | string | No | No | Content of the inserted text. |
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| deleteOffset | number | No | No | Position index of the deleted value, starting from 0. |
| direction | TextDeleteDirection | No | No | Direction for deleting the text. |
| deleteValue | string | No | No | Content of the deleted text. |
This configuration is only available for the Text and RichEditor components.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| types | TextDataDetectorType[] | No | No | Sets the entity types for text recognition. If types is set to null or [], all entity types are recognized; otherwise, only the specified entity types are recognized. Atomic service API: This API can be used in atomic services since API version 12. |
| onDetectResultUpdate | Callback<string> | No | Yes | Callback invoked when text recognition succeeds. Default value: undefined, which means the callback is not triggered. Atomic service API: This API can be used in atomic services since API version 12. |
| color12+ | ResourceColor | No | Yes | Sets the entity color after text recognition succeeds. Default value: '#ff0a59f7', which indicates blue (with 100% opacity). Atomic service API: This API can be used in atomic services since API version 12. |
| decoration12+ | DecorationStyleInterface | No | Yes | Sets the decoration line style of entities after text recognition succeeds. Default value: { type: TextDecorationType.Underline, color: same as the entity color, style: TextDecorationStyle.SOLID } Atomic service API: This API can be used in atomic services since API version 12. |
| enablePreviewMenu20+ | boolean | No | Yes | Sets whether to enable the preview menu displayed on long press after text recognition. The value true indicates enabled, and false indicates disabled. Default value: false When copyOptions is set to None, the preview menu is not displayed on long press of an AI entity even if enablePreviewMenu is set to true. Device behavior differences: The actual device types supported by this API (phones and tablets) are fewer than those supported by its system capability (phones, 2-in-1 devices, tablets, TVs, cars, and wearables). Due to hardware form limitations, this API does not respond on 2-in-1 devices, TVs, cars, and wearables. Atomic service API: This API can be used in atomic services since API version 20. |
Preview text.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| offset | number | No | No | Start position index of the preview text, starting from 0. |
| value | string | No | No | Content of the preview text. |
Defines font setting options.
Widget capability: This API can be used in ArkTS widgets since API version 12.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| enableVariableFontWeight | boolean | No | Yes | Whether to enable variable font weight adjustment. This font configuration item is used as an input parameter of the fontWeight API. When the value of weight in the fontWeight API is a non-multiple-of-100 value within [100, 900], enableVariableFontWeight determines whether the value of weight takes effect. Default value: false true: Variable font weight adjustment is enabled. In this case, if the value of weight is any integer within [100, 900], the font weight is the value of weight; otherwise, the default value 400 is used. false: Variable font weight adjustment is disabled. In this case, if the value of weight is a multiple of 100 within [100, 900], the font weight is the value of weight; if weight is a non-multiple-of-100 value, the default value 400 is used. |
Defines font configurations.
Atomic service API: This API can be used in atomic services since API version 24.
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| fontWeightConfigs | FontWeightConfigs | No | Yes | Font weight configuration. The default value inherits from FontWeightConfigs. Model restriction: This API can be used only in the stage model. |
Defines font weight configurations. When the configuration object (including an empty object {}) is passed, the default values are used for properties that are not explicitly set. When null or undefined is passed, default values are not applied, and the font weight behavior is consistent with that of the parent component text.
Atomic service API: This API can be used in atomic services since API version 24.
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| enableVariableFontWeight | boolean | No | Yes | Whether to enable variable font weight adjustment. When the font weight value weight is set to a non-hundred value within [100, 900], enableVariableFontWeight determines whether the weight value takes effect. Default value: false true: Variable font weight adjustment is enabled. In this case, if weight is any integer within [100, 900], the font weight is weight; otherwise, the default value 400 is used. false: Variable font weight adjustment is disabled. In this case, if weight is a hundred value within [100, 900], the font weight is weight; if weight is a non-hundred value, the default value 400 is used. |
| enableDeviceFontWeightCategory | boolean | No | Yes | Whether to automatically update the font weight based on the device font weight level. Default value: true true: When the device font weight level changes, the font weight is automatically updated. false: When the device font weight level changes, the font weight is not automatically updated. |
type OnDidChangeCallback = (rangeBefore: TextRange, rangeAfter: TextRange) => void
Represents the callback invoked after text changes.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
Defines the listener for changes of the styled string text content.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| onWillChange | Callback<StyledStringChangeValue, boolean> | No | Yes | Callback invoked when the text content is about to change. Default value: null, which means no callback is triggered. The value true indicates that the text content change is allowed, and false indicates that the change is blocked. |
| onDidChange | OnDidChangeCallback | No | Yes | Callback invoked when the text content change is complete. Default value: null, which means no callback is triggered. |
Describes the text changes of the styled string.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| range | TextRange | No | No | Range of the styled string to be replaced in the original string. |
| replacementString | StyledString | No | No | Styled string used for replacement. |
| previewText | StyledString | No | Yes | Preview content attribute string. Default value: null, indicating no preview content. This attribute is used to represent the temporary input content that has not been committed to the screen in voice input, camera input, and input method preview text scenarios. |
Automatic capitalization mode type. It only provides the API capability, and the specific implementation is determined by the input method app.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Value | Description |
|---|---|---|
| NONE | 0 | Default state. No automatic capitalization is performed. |
| WORDS | 1 | Automatic capitalization is applied per word: The first character of each word is capitalized, others are lowercase. |
| SENTENCES | 2 | Automatic capitalization is applied per sentence: The first character of each sentence is capitalized, others are lowercase. |
| ALL_CHARACTERS | 3 | Automatic capitalization applied to all characters. |
Defines a text selection controller.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
setSelection(selectionStart: number, selectionEnd: number, options?: SelectionOptions): void
Sets the range of content selection. The selected content is highlighted.
If both selectionStart and selectionEnd are set to -1, the entire content is selected.
The component must be focused for the API call to have effect.
Since API version 12, on PC/2-in-1 devices, calling the setSelection API does not pop up a menu regardless of the value of options. In addition, if a menu already exists in the component, calling the setSelection API closes the menu.
On non-2-in-1 devices, when options is set to MenuPolicy.DEFAULT, the following rules apply after the API is called:
If the component has a menu with a selection handle, the menu remains open and is relocated according to the selection.
If the component has a menu without a selection handle, the menu remains open and its position remains unchanged.
If there is no menu open, no menu will appear after the selection.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| selectionStart | number | Yes | Start position of the selection. If the value is less than 0, it is processed as 0. If the value is greater than the text length, it is processed as the current text length. Special value effect: when both selectionStart and selectionEnd are -1, all text is selected. |
| selectionEnd | number | Yes | End position of the selection. If the value is less than 0, it is processed as 0. If the value is greater than the text length, it is processed as the current text length. Special value effect: when both selectionStart and selectionEnd are -1, all text is selected. |
| options | SelectionOptions | No | Configuration of options. The default value is inherited from SelectionOptions. |
getLayoutManager(): LayoutManager
Obtains a LayoutManager object.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Return value
| Type | Description |
|---|---|
| LayoutManager | Layout manager object, used to obtain text layout information, such as the number of lines, line metrics, glyph positions, and so on. |
Implements an extended text editing controller.
Inherits TextBaseController.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
isEditing(): boolean
Obtains the editing status of the rich text.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Return value
| Type | Description |
|---|---|
| boolean | Editing status of the rich text. true means that the text is in editable state, and false means the opposite. |
stopEditing(): void
Stops editing.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
getCaretOffset(): number
Obtains the current position of the caret.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Return value
| Type | Description |
|---|---|
| number | Position of the caret. |
setCaretOffset(offset: number): boolean
Sets the offset of the caret.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| offset | number | Yes | Cursor offset position. The value range is [0, text length]. If the value exceeds the content range, the setting fails. |
Return value
| Type | Description |
|---|---|
| boolean | Whether the cursor is set successfully. The value true indicates that the cursor is set successfully, and false indicates the opposite. |
getPreviewText?(): PreviewText
Obtains the preview text.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Return value
| Type | Description |
|---|---|
| PreviewText | Preview text information, including the start position index and text content of the preview text. |
Defines a styled string controller.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
setStyledString(styledString: StyledString): void
Sets the styled string displayed in the rich text component.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| styledString | StyledString | Yes | Styled string. NOTE A subclass of StyledString, MutableStyledString, can also be used as the input parameter value. |
getStyledString(): MutableStyledString
Obtains the styled string displayed in the rich text component.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
Return value
| Type | Description |
|---|---|
| MutableStyledString | Styled string displayed in the rich text component. |
Provides the text decoration information returned by the backend.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| type | TextDecorationType | No | No | Type of the decoration line. Atomic service API: This API can be used in atomic services since API version 12. |
| color | ResourceColor | No | No | Color of the decoration line. Atomic service API: This API can be used in atomic services since API version 12. |
| style | TextDecorationStyle | No | Yes | Style of the decoration line. Default value: TextDecorationStyle.SOLID Atomic service API: This API can be used in atomic services since API version 12. |
| thicknessScale20+ | number | No | Yes | Scale ratio of the decoration line thickness. Default value: 1.0 Value range: [0, +∞) Note: A negative value is processed as the default value. Atomic service API: This API can be used in atomic services since API version 20. |
type LineMetrics = import('../api/@ohos.graphics.text').default.LineMetrics
Describes the measurement information of a single line in the text layout.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Type | Description |
|---|---|
| import('../api/@ohos.graphics.text').default.LineMetrics | Describes the metrics of a single line of text in the text layout. |
type Affinity = import('../api/@ohos.graphics.text').default.Affinity
Enumerates the affinity modes.
Atomic service API: This API can be used in atomic services since API version 12.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Type | Description |
|---|---|
| import('../api/@ohos.graphics.text').default.Affinity | Position affinity enum. |
type TextBox = import('../api/@ohos.graphics.text').default.TextBox
Describes the rectangle that contains the text.
Atomic service API: This API can be used in atomic services since API version 14.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Type | Description |
|---|---|
| import('../api/@ohos.graphics.text').default.TextBox | Text box area. |
type Paragraph = import('../api/@ohos.graphics.text').default.Paragraph
Implements a carrier that stores the text content and style. It supports operations such as layout and drawing.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Type | Description |
|---|---|
| import('../api/@ohos.graphics.text').default.Paragraph | Carrier that stores text content and styles, and supports layout and drawing operations. |
type RectHeightStyle = import('../api/@ohos.graphics.text').default.RectHeightStyle
Enumerates the rectangle height styles.
Atomic service API: This API can be used in atomic services since API version 14.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Type | Description |
|---|---|
| import('../api/@ohos.graphics.text').default.RectHeightStyle | Enumerates the height specifications of a rectangular area. |
type RectWidthStyle = import('../api/@ohos.graphics.text').default.RectWidthStyle
Enumerates the rectangle width styles.
Atomic service API: This API can be used in atomic services since API version 14.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Type | Description |
|---|---|
| import('../api/@ohos.graphics.text').default.RectWidthStyle | Enumerates the width specifications of a rectangular area. |
Text encoding types supported by the text layout query APIs.
Since: 26.0.0
Atomic service API: This API can be used in atomic services since API version 26.0.0.
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Value | Description |
|---|---|---|
| TEXT_ENCODING_UTF8 | 0 | UTF-8 encoding. |
| TEXT_ENCODING_UTF16 | 1 | UTF-16 encoding. |
Text change information, including the selection range before and after the change and the text content before the change.
Atomic service API: This API can be used in atomic services since API version 15.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| rangeBefore | TextRange | No | No | Selection range before the change. |
| rangeAfter | TextRange | No | No | Selection range after the change. |
| oldContent | string | No | No | Text content before the change. |
| oldPreviewText | PreviewText | No | No | Preview text before the change. |
Provides detailed information of text changes, including preview text.
Atomic service API: This API can be used in atomic services since API version 15.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| content | string | No | No | Current text content. |
| previewText | PreviewText | No | Yes | Preview text content. Default value: undefined, which means there is no preview text content. |
| options | TextChangeOptions | No | Yes | Changed text content information. Default value: undefined. |
Defines the base class for text shader effects.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
Displays a linear gradient. LinearGradientStyle inherits from ShaderStyle.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| options | LinearGradientOptions | No | No | Options for displaying a linear gradient. |
constructor(options: LinearGradientOptions)
A constructor used to create a LinearGradientStyle object.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| options | LinearGradientOptions | Yes | Displays a linear gradient effect. The default value of direction in LinearGradientOptions is processed as NONE in GradientDirection. |
Displays a radial gradient. RadialGradientStyle inherits from ShaderStyle.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| options | RadialGradientOptions | No | No | Options for displaying a radial gradient. |
constructor(options: RadialGradientOptions)
A constructor used to create a RadialGradientStyle object.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| options | RadialGradientOptions | Yes | Options for displaying a radial gradient. |
Displays a solid color. ColorShaderStyle inherits from ShaderStyle.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| color | ResourceColor | No | No | Options for displaying a solid color. |
constructor(color: ResourceColor)
A constructor used to create a ColorShaderStyle object.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| color | ResourceColor | Yes | Options for displaying a solid color. |
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| nodeId | number | No | No | Unique ID of the current input component. The value must be greater than or equal to 0. |
setExtraConfig(config: InputMethodExtraConfig): void
Sets the extension configuration of an input method.
Atomic service API: This API can be used in atomic services since API version 22.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| config | InputMethodExtraConfig | Yes | Extension configuration of an input method. |
Configures the display effect of the TextArea component when the text exceeds the maximum number of lines.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| overflowMode | MaxLinesMode | No | Yes | overflowMode configures the non-inline mode of the TextArea component. When the number of lines exceeds the configured maxLines, scrolling is enabled. It must be used together with textOverflow, and MaxLinesMode takes effect only when textOverflow is set to None or Clip. By default, the value of MaxLinesMode is Clip, and text is truncated when the number of lines exceeds maxLines. |
Enumerates the display effects of the TextArea component when text exceeds the maximum number of lines. The default value is CLIP (truncating text at the maximum line count).
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Value | Description |
|---|---|---|
| CLIP | 0 | Text is clipped when it exceeds the maximum number of lines. |
| SCROLL | 1 | Text can be scrolled when it exceeds the maximum number of lines. |
Configures the line spacing of text and whether it applies only between lines.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| onlyBetweenLines | boolean | No | Yes | Whether the line spacing of the text takes effect only between lines. When set to true, the line spacing applies only between lines, with no extra line spacing above the first line or below the last line. When set to false, line spacing exists both above the first line and below the last line. Default value: false |
Defines the vertical alignment mode of text. The default value is BASELINE (aligning along the baseline).
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Value | Description |
|---|---|---|
| BASELINE | 0 | Aligns text along the baseline. |
| BOTTOM | 1 | Aligns text to the bottom. |
| CENTER | 2 | Aligns text vertically to the center. |
| TOP | 3 | Aligns text to the top. |
Defines the base class for text transitions.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
Implements a flip animation for numeric text. It applies only to positive integers (decimals and negative numbers are not supported). Gradient colors and text marquee mode are not supported. Text selection is not supported, and the copyOption property is ineffective. The flip animation fails if the text contains child components or is set via a styled string.
NumericTextTransition inherits from ContentTransition.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| flipDirection | FlipDirection | No | Yes | Direction of the flip animation. Default value: FlipDirection.DOWN |
| enableBlur | boolean | No | Yes | Whether to enable the blur effect for the flip animation. Default value: false true: Enable the blur effect. false: Disable the blur effect. |
constructor(options?: NumericTextTransitionOptions)
A constructor used to create a NumericTextTransition object.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
Parameters
| Name | Type | Mandatory | Description |
|---|---|---|---|
| options | NumericTextTransitionOptions | No | Options of the numeric flip animation. The default value is inherited from NumericTextTransitionOptions. |
Defines the options of the numeric flip animation.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| flipDirection | FlipDirection | No | Yes | Direction of the flip animation. Default value: FlipDirection.DOWN |
| enableBlur | boolean | No | Yes | Whether to enable the blur effect for the flip animation. Default value: false true: Enable the blur effect. false: Disable the blur effect. |
Enumerates the directions of the flip animation. The default value is DOWN.
Atomic service API: This API can be used in atomic services since API version 20.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Value | Description |
|---|---|---|
| DOWN | 0 | Content flips downward. |
| UP | 1 | Content flips upward. |
Defines the text layout options.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| constraintWidth | LengthMetrics | No | Yes | Layout width of the measured text. If not set, the width is the maximum width occupied by a single-line layout. |
Defines the drag preview style for selected text.
Atomic service API: This API can be used in atomic services since API version 23.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| color | ResourceColor | No | Yes | Used to set the background color of the text during dragging. Default value: follows the theme. With the default theme, white is displayed in light mode and black in dark mode. |
Enumerates the vertical alignment directions of the text content area.
Atomic service API: This API can be used in atomic services since API version 21.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Value | Description |
|---|---|---|
| TOP | 0 | Aligns the content area to the top. |
| CENTER | 1 | Aligns the content area to the center. |
| BOTTOM | 2 | Aligns the content area to the bottom. |
Defines the style of line corners, that is, the brush style at the corners of line segments when drawing polylines.
Since: 26.0.0
Atomic service API: This API can be used in atomic services since API version 26.0.0.
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Value | Description |
|---|---|---|
| MITER_JOIN | 0 | The corner type is a sharp angle. |
| ROUND_JOIN | 1 | The corner type is a round angle. |
| BEVEL_JOIN | 2 | The corner type is a flat angle. |
Enumerates the text layout directions.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Name | Value | Description |
|---|---|---|
| LTR | 0 | Text layout direction is from left to right. Atomic service API: This API can be used in atomic services since API version 22. |
| RTL | 1 | Text layout direction is from right to left. Atomic service API: This API can be used in atomic services since API version 22. |
| DEFAULT23+ | 2 | The text layout direction follows the component layout direction. Atomic service API: This API can be used in atomic services since API version 23. |
| AUTO23+ | 3 | The layout direction follows the actual text content. If the text is in an RTL (Right-to-Left) language (such as Tibetan or Uyghur), the text layout direction is from right to left. If the text is in an LTR (Left-to-Right) language (such as Chinese or English), the text layout direction is from left to right. Atomic service API: This API can be used in atomic services since API version 23. |
type InputMethodExtraConfig = import('../api/@ohos.inputMethod.ExtraConfig').InputMethodExtraConfig
Represents the extension configuration of an input method.
Atomic service API: This API can be used in atomic services since API version 22.
System capability: SystemCapability.ArkUI.ArkUI.Full
| Type | Description |
|---|---|
| import('../api/@ohos.inputMethod.ExtraConfig').InputMethodExtraConfig | Extended information of the input method. |
Defines accessibility options for the span.
Atomic service API: This API can be used in atomic services since API version 23.
Model restriction: This API can be used only in the stage model.
System capability: SystemCapability.ArkUI.ArkUI.Full
Device behavior differences: On wearables, calling this API results in a runtime exception indicating that the API is undefined. On other devices, the API works correctly.
| Name | Type | Read-Only | Optional | Description |
|---|---|---|---|---|
| accessibilityText | ResourceStr | No | Yes | Accessibility text, that is, accessible label name. If a component has no text property, it will not be announced when selected by a screen reader. Setting this property allows you to define accessibility text for such components, which will be announced by a screen reader to help users identify the selected component. Default value: '' If the value is undefined, the default value is used. |
| accessibilityDescription | ResourceStr | No | Yes | Accessibility description. This description provides users with a detailed explanation of the current component to help users understand the intended operation and its consequences, especially when these consequences cannot be directly obtained from the component's attributes and accessibility text alone. Default value: '' If the value is undefined, the default value is used. |
| accessibilityLevel | string | No | Yes | Accessibility importance. Used to set whether the component can be recognized by the accessibility service. The following values are supported: "auto": The accessibility service and ArkUI comprehensively determine whether the component can be recognized by the accessibility service. "yes": The component can be recognized by the accessibility service. "no": The component cannot be recognized by the accessibility service. "no-hide-descendants": The component and all its child components cannot be recognized by the accessibility service. Default value: "auto" If the value is undefined, the default value is used. NOTE When accessibilityLevel is set to "auto", whether the component can be recognized by the accessibility service depends on the following factors: 1. Whether the component can be recognized is determined internally by the accessibility service, which makes its own choice. 2. If isGroup in the accessibilityGroup attribute of the parent component is set to true, the accessibility service no longer focuses on the content of its child components, and the component cannot be recognized by the accessibility service. 3. If the accessibilityLevel attribute of the parent component is set to "no-hide-descendants", the component cannot be recognized by the accessibility service. |
type FontVariation = import('../api/@ohos.graphics.text').default.FontVariation
Properties of a variable font.
Since: 26.0.0
Atomic service API: This API can be used in atomic services since API version 26.0.0.
System capability: SystemCapability.ArkUI.ArkUI.Full
Model restriction: This API can be used only in the stage model.
| Type | Description |
|---|---|
| import('../api/@ohos.graphics.text').default.FontVariation | Properties of a variable font. |