openharmony 鸿蒙 ts-types

2025-06-12 浏览 (1)

Basic Types

NOTE

The initial APIs of this module are supported since API version 7. Newly added APIs will be marked with a superscript to indicate their earliest API version.

Resource

Atomic service API: This API can be used in atomic services since API version 11.

The Resource type is used to reference resources for setting component attributes.

You can use $r or $rawfile to create a Resource object, but its attribute values cannot be changed.

  • $r('belonging.type.name')

    belonging: group to which the resource belongs, which can be 'sys' or 'app'.

    type: resource type, which can be 'boolean', 'color', 'float', 'intarray', 'integer', 'pattern', 'plural', 'strarray', 'string', or 'media'.

    name: resource name, which is determined during resource definition.

  • $rawfile('filename')

    filename: name of the file in the resources/rawfile directory of the project.

    NOTE
    When referencing resources of the Resource type, make sure the data type is the same as that of the attribute method. For example, if an attribute method supports the string|Resource types, the data type of the Resource type must be string.

Length

The Length type is used to represent a size unit.

Atomic service API: This API can be used in atomic services since API version 11.

TypeDescription
stringString type. Specify the length unit explicitly, for example, '10px', or provide the length in percentage, for example, '100%'.
NOTE
If the unit is not specified, the default unit vp is used, in which case '10' is equivalent to 10 vp.
numberNumber type. The default unit is vp.
ResourceSize referenced from system or application resources.

ResourceStr

The ResourceStr type is used to represent the types that can be used by input parameters of the string type.

Atomic service API: This API can be used in atomic services since API version 11.

TypeDescription
stringString type.
ResourceString referenced from system or application resources.

Padding

The Padding type is used to describe the paddings in different directions of a component.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
topLengthNoHeight of the padding on the top of the component.
rightLengthNoWidth of the padding on the right of the component.
bottomLengthNoHeight of the padding at the bottom of the component.
leftLengthNoWidth of the padding on the left of the component.

LocalizedPadding12+

The Padding type is used to describe the paddings in different directions of a component.

NameTypeMandatoryDescription
topLengthMetrics12+NoHeight of the padding on the top of the component.
endLengthMetrics12+NoWidth of the padding on the right of the component.
For right-to-left scripts:
Width of the padding on the left of the component.
bottomLengthMetrics12+NoHeight of the padding at the bottom of the component.
startLengthMetrics12+NoWidth of the padding on the left of the component.
For right-to-left scripts:
Width of the padding on the right of the component.

Margin

The Margin type is used to describe the margins in different directions of a component.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
topLengthNoHeight of the margin above the component.
rightLengthNoWidth of the margin on the right of the component.
bottomLengthNoHeight of the margin below the component.
leftLengthNoWidth of the margin on the left of the component.

LocalizedMargin12+

The Margin type is used to describe the margins in different directions of a component.

NameTypeMandatoryDescription
topLengthMetrics12+NoHeight of the margin above the component.
endLengthMetrics12+NoWidth of the margin on the right of the component.
For right-to-left scripts:
Width of the margin on the left of the component.
bottomLengthMetrics12+NoHeight of the margin below the component.
startLengthMetrics12+NoWidth of the margin on the left of the component.
For right-to-left scripts:
Width of the margin on the right of the component.

EdgeWidths9+

The EdgeWidths type is used to describe the edge widths in different directions of a component.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
topLengthNoWidth of the top edge of the component.
rightLengthNoWidth of the right edge of the component.
bottomLengthNoWidth of the bottom edge of the component.
leftLengthNoWidth of the left edge of the component.

LocalizedEdgeWidths12+

The EdgeWidths type is used to describe the edge widths in different directions of a component.

NameTypeMandatoryDescription
topLengthMetrics12+NoWidth of the top edge of the component.
endLengthMetrics12+NoWidth of the right edge of the component.
Width of the left edge of the component for right-to-left scripts.
bottomLengthMetrics12+NoWidth of the bottom edge of the component.
startLengthMetrics12+NoWidth of the left edge of the component.
Width of the right edge of the component for right-to-left scripts.

BorderRadiuses9+

The BorderRadiuses type is used to describe the corner radius of a component's border.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
topLeftLengthNoRadius of the upper left corner of the component.
topRightLengthNoRadius of the upper right corner of the component.
bottomLeftLengthNoRadius of the lower left corner of the component.
bottomRightLengthNoRadius of the lower right corner of the component.

LocalizedBorderRadiuses12+

The LocalizedBorderRadiuses type is used to describe the corner radius of a component's border.

NameTypeMandatoryDescription
topStartLengthMetrics12+NoRadius of the upper left corner of the component.
For right-to-left scripts, this indicates the radius of the upper left right of the component.
topEndLengthMetrics12+NoRadius of the upper right corner of the component.
For right-to-left scripts, this indicates the radius of the upper left corner of the component.
bottomStartLengthMetrics12+NoRadius of the lower left corner of the component.
For right-to-left scripts, this indicates the radius of the lower right corner of the component.
bottomEndLengthMetrics12+NoRadius of the lower right corner of the component.
For right-to-left scripts, this indicates the radius of the lower left corner of the component.

EdgeColors9+

The EdgeColors type is used to describe the edge colors of a component.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
topResourceColorNoColor of the top edge of the component.
rightResourceColorNoColor of the right edge of the component.
bottomResourceColorNoColor of the bottom edge of the component.
leftResourceColorNoColor of the left edge of the component.

LocalizedEdgeColors12+

The EdgeColors type is used to describe the edge colors of a component.

Atomic service API: This API can be used in atomic services since API version 12.

NameTypeMandatoryDescription
topResourceColorNoColor of the top edge of the component.
endResourceColorNoColor of the right edge of the component.
Color of the left edge of the component for right-to-left scripts.
bottomResourceColorNoColor of the bottom edge of the component.
startResourceColorNoColor of the left edge of the component.
Color of the right edge of the component for right-to-left scripts.

EdgeStyles9+

The EdgeStyles type is used to describe the edge styles of a component.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
topBorderStyleNoStyle of the top edge of the component.
rightBorderStyleNoStyle of the right edge of the component.
bottomBorderStyleNoStyle of the bottom edge of the component.
leftBorderStyleNoStyle of the left edge of the component.

Offset

The Offset type is used to describe the offset coordinates of a component in the layout.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
dxLengthYesX coordinate of the offset.
dyLengthYesY coordinate of the offset.

RectResult10+

The RectResult type is used to describe the position, width, and height of a component.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeDescription
xnumberHorizontal coordinate.
ynumberVertical coordinate.
widthnumberContent width.
heightnumberContent height.

ResourceColor

The ResourceColor type is used to describe the color types of resources.

Atomic service API: This API can be used in atomic services since API version 11.

TypeDescription
ColorColor enums.
numberColor in hexadecimal notation. RGB and ARGB are supported. Examples: 0xffffff and 0xffff0000. The number of input digits cannot be identified. The format is selected based on the value. For example, 0x00ffffff is parsed in RGB format.
stringColor in RGB or ARGB notation. Example: '#ffffff', '#ff000000', 'rgb(255, 100, 255)', 'rgba(255, 100, 255, 0.5)'
ResourceColor referenced from system or application resources.

LengthConstrain

The LengthConstrain type is used to describe the maximum and minimum lengths of a component.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
minLengthLengthYesMinimum length of the component.
maxLengthLengthYesMaximum length of the component.

Font

The Font type is used to set the text style.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
sizeLengthNoFont size. If the value is of the number type, the unit fp is used. The value cannot be a percentage.
Default value: 16.0
weightFontWeight |number |stringNoFont weight. For the number type, the value ranges from 100 to 900, at an interval of 100. A larger value indicates a thicker font.
Default value: 400 |FontWeight.Normal
familystring |ResourceNoFont family of the text. Use commas (,) to separate multiple fonts. The priority of the fonts is the sequence in which they are placed. An example value is 'Arial, HarmonyOS Sans'. The 'HarmonyOS Sans' font and registered custom fonts are supported.
styleFontStyleNoFont style.
Default value: FontStyle.Normal

Area8+

The Area type is used to describe the area information of a component.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeDescription
widthLengthWidth of the component. The value is of the number type in vp when used as the return value.
heightLengthHeight of the component. The value is of the number type in vp when used as the return value.
positionPositionPosition of the upper left corner of the component relative to that of its parent container.
globalPositionPositionPosition of the upper left corner of the component relative to that of the page where the component resides.

Position

The Position type is used to represent coordinates of a point.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
xLengthNoX coordinate. The value is of the number type in vp when used as the return value.
yLengthNoY coordinate. The value is of the number type in vp when used as the return value.

LocalizedPosition12+

The LocalizedPosition type is used to represent coordinates of a point.

NameTypeMandatoryDescription
startLengthMetricsNoX-coordinate relative to the left for left-to-right scripts; X-coordinate relative to the right for right-to-left scripts.
topLengthMetricsNoY-coordinate.

Edges12+

The Edges type is used to describe the offset relative to the four edges. If both top and bottom are set, only top takes effect. If both left and right are set, only left takes effect.

Atomic service API: This API can be used in atomic services since API version 12.

NameTypeMandatoryDescription
topDimensionNoOffset relative to the top edge.
bottomDimensionNoOffset relative to the bottom edge.
leftDimensionNoOffset relative to the left edge.
rightDimensionNoOffset relative to the right edge.

LocalizedEdges12+

The LocalizedEdges type is used to describe the offset relative to the four edges. If both top and** bottom **are set, only top takes effect. If both start and end are set, only start takes effect.

NameTypeMandatoryDescription
topLengthMetricsNoOffset relative to the top edge.
bottomLengthMetricsNoOffset relative to the bottom edge.
startLengthMetricsNoOffset relative to the left for left-to-right scripts; offset relative to the right for right-to-left scripts.
endLengthMetricsNoOffset relative to the right for left-to-right scripts; offset relative to the left for right-to-left scripts.

ConstraintSizeOptions

The ConstraintSizeOptions type is used to set the size constraints of a component during component layout.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
minWidthLengthNoMinimum width of the component.
maxWidthLengthNoMaximum width of the component.
minHeightLengthNoMinimum height of the component.
maxHeightLengthNoMaximum height of the component.

SizeOptions

The SizeOptions type is used to set the width and height.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
widthLengthNoWidth of the component.
heightLengthNoHeight of the component.

BorderOptions

The BorderOptions type is used to provide border information.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
widthLength |EdgeWidths9+ |LocalizedEdgeWidths12+NoBorder width.
colorResourceColor |EdgeColors9+NoBorder color.
radiusLength |BorderRadiuses9+NoRadius of the rounded corner border.
styleBorderStyle |EdgeStyles9+NoBorder style.

ColorFilter9+

The ColorFilter type is used to create a color filter with a 4 x 5 matrix.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
constructornumber[]YesConstructor for creating a color filter with a 4*5 matrix. The input parameter is [m*n], which is the matrix value in row m and column n. The matrix is row-first.

CustomBuilder8+

The CustomBuilder type is used to define custom UI descriptions in component attribute methods.

NameTypeDescription
CustomBuilder() => any |voidBuilder for creating a custom component; must be used with @Builder. For details, see @Builder.

MarkStyle10+

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeMandatoryDefault ValueDescription
strokeColorResourceColorNoColor.WhiteColor of the mark.
sizeLengthNo-Size of the mark, in vp. The default size is the same as the width of the check box.
This parameter cannot be set in percentage. If it is set to an invalid value, the default value is used.
strokeWidthLengthNo2Stroke width of the mark, in vp. This parameter cannot be set in percentage. If it is set to an invalid value, the default value is used.

ModalTransition10+

The ModalTransition type is used to set the transition type for a full-screen modal.

Atomic service API: This API can be used in atomic services since API version 11.

NameDescription
NONENo transition animation for the modal.
DEFAULTSlide-up and slide-down animation for the modal.
ALPHAOpacity gradient animation for the modal.

Dimension10+

The Length type is used to represent a size unit.

Atomic service API: This API can be used in atomic services since API version 11.

TypeDescription
PXPhysical pixel unit type. The unit px must be included, for example, '10px'.
VPPixel unit type specific to the screen density. The unit vp can be included or omitted, for example, 10 or '10vp'.
FPFont pixel unit type. The unit fp must be included, for example, '10fp'.
LPXLogical pixel unit type. The unit lpx must be included, for example, '10lpx'.
PercentagePercentage type. The unit % must be included, for example, '10%'.
ResourceSize referenced from system or application resources.

PX10+

The PX type is used to represent a length in px.

Atomic service API: This API can be used in atomic services since API version 11.

TypeDescription
{number}pxPhysical pixel unit type. The unit px must be included, for example, '10px'.

VP10+

The VP type is used to represent a length in vp.

Atomic service API: This API can be used in atomic services since API version 11.

TypeDescription
{number}vp|numberPixel unit type specific to the screen density. The unit vp can be included or omitted, for example, 10 or '10vp'.

FP10+

The FP type is used to represent a length in fp.

Atomic service API: This API can be used in atomic services since API version 11.

TypeDescription
{number}fpFont pixel unit type. The unit fp must be included, for example, '10fp'.

LPX10+

The LPX type is used to represent a length in lpx.

Atomic service API: This API can be used in atomic services since API version 11.

TypeDescription
{number}lpxLogical pixel unit type. The unit lpx must be included, for example, '10lpx'.

Percentage10+

The Percentage type is used to represent a length in percentage.

Atomic service API: This API can be used in atomic services since API version 11.

TypeDescription
{number}%Percentage type. The unit % must be included, for example, '10%'.

Degree10+

The Degree type is used to represent a length in deg.

Atomic service API: This API can be used in atomic services since API version 11.

TypeDescription
{number}degDegree type. The unit deg must be included, for example, '10deg'.

MultiShadowOptions10+

The MultiShadowOptions type is used to describe the shadow style.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
radiusnumber |ResourceNoShadow blur radius.
The default value varies by API version.
API version 10 and earlier versions: 5
Since API version 11: 20
Unit: vp
NOTE
A value less than or equal to 0 is handled as the default value.
offsetXnumber |ResourceNoOffset on the x-axis.
Default value: 5
Unit: vp
offsetYnumber |ResourceNoOffset on the y-axis.
Default value: 5
Unit: vp

SafeAreaType10+

The SafeAreaType type is used to describe the types of expanded safe areas.

Atomic service API: This API can be used in atomic services since API version 11.

NameDescription
SYSTEMDefault non-safe area of the system, including the status bar and navigation bar.
CUTOUTNon-safe area of the device, for example, the notch area.
KEYBOARDSoft keyboard area.

SafeAreaEdge10+

The SafeAreaEdge type is used to define the edge for expanding the safe area.

Atomic service API: This API can be used in atomic services since API version 11.

NameDescription
TOPTop edge.
BOTTOMBottom edge.
STARTStart edge.
ENDEnd edge.

KeyboardAvoidMode12+

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameValueDescription
DEFAULT0Automatically avoids the soft keyboard and compresses the height when reaching the maximum limit.
NONE1Does not avoid the soft keyboard.

LayoutSafeAreaType12+

The LayoutSafeAreaType type is used to describe the types of expanded safe areas in layout.

NameDescription
SYSTEMDefault non-safe area of the system, including the status bar and navigation bar.

LayoutSafeAreaEdge12+

The LayoutSafeAreaEdge type is used to define the edge for expanding the safe area.

NameDescription
TOPTop edge.
BOTTOMBottom edge.

TouchPoint11+

The TouchPoint type is used to define the coordinates of the touch point.

Atomic service API: This API can be used in atomic services since API version 12.

NameTypeDescription
XDimensionX coordinate of the touch point.
YDimensionY coordinate of the touch point.

PixelRoundPolicy11+

The PixelRoundPolicy type is used to describe the direction of pixel rounding at the component level.

Atomic service API: This API can be used in atomic services since API version 11.

NameTypeMandatoryDescription
startPixelRoundCalcPolicyNoRounding for alignment with the start edge.
topPixelRoundCalcPolicyNoRounding for alignment with the top edge.
endPixelRoundCalcPolicyNoRounding for alignment with the end edge.
bottomPixelRoundCalcPolicyNoRounding for alignment with the bottom edge.

VoidCallback12+

type VoidCallback: () => void;

Atomic service API: This API can be used in atomic services since API version 12.

Callback12+

Callback<T,V = void> = (data: T) => V;

The Callback type is used to represent the callback with parameters.

Atomic service API: This API can be used in atomic services since API version 12.

HoverCallback12+

The HoverCallback type is used to represent the callback for the hover event.

type HoverCallback = (isHover: boolean, event: HoverEvent) => void;

Atomic service API: This API can be used in atomic services since API version 12.

NameTypeDescription
HoverCallback(isHover: boolean, event: HoverEvent) => voidCallback for the hover event.

VisibleAreaEventOptions12+

The VisibleAreaEventOptions type is used to describe visible area changes.

Atomic service API: This API can be used in atomic services since API version 12.

NameTypeMandatoryDescription
ratiosArray<number>YesThreshold array. Each threshold represents a ratio of the component's visible area (that is, the area of the component that is visible on screen; only the area within the parent component is counted) to the component's total area. The value range of the threshold is [0.0, 1.0]. If the threshold set exceeds this range, the value 0.0 or 1.0 will be used.
expectedUpdateIntervalnumberNoExpected update interval, in milliseconds. You can set it as appropriate. Default value: 1000

VisibleAreaChangeCallback12+

The VisibleAreaChangeCallback type is used to represent a callback for visible area changes of the component.

type VisibleAreaChangeCallback = (isExpanding: boolean, currentRatio: number) => void;

Atomic service API: This API can be used in atomic services since API version 12.

NameTypeDescription
VisibleAreaChangeCallback(isExpanding: boolean, currentRatio: number) => voidCallback for visible area changes of the component.
- isExpanding: whether the ratio of the component's visible area to its total area is greater than the previous one. The value true means that the ratio is greater than the previous one, and false means the opposite.
- currentRatio: ratio of the component's visible area to its total area when this callback is invoked.

DividerStyleOptions12+

The DividerStyleOptions type is used to provide the information about the divider.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeMandatoryDescription
strokeWidthLengthMetrics12+NoWidth of the divider.
colorResourceColorNoColor of the divider.
startMarginLengthMetrics12+NoDistance between the divider and the start edge of the menu.
endMarginLengthMetrics12+NoDistance between the divider and the end edge of the menu.
modeDividerMode18+NoMode of the divider.

TextContentControllerBase10+

The TextContentControllerBase type is used to represent the base controller for TextInput, TextArea, and Search components.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

getTextContentRect10+

getTextContentRect(): RectResult

The getTextContentRect type is used to obtain the position of the edited text area relative to the component and its size. The unit of the return value is pixel.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Return value

TypeDescription
RectResultPosition of the edited text area relative to the component and its size.

NOTE

  • If no text is entered, the return value contains the position information, but the size is 0.
  • The position information is the offset of the first character relative to the editable area.
  • For the Search component, the returned position information is the offset of the first character relative to the search icon in the component.
  • If there is input, the width in the return value is the fixed width of the editable area.

getTextContentLineCount10+

getTextContentLineCount(): number

The getTextContentLineCount type is used to obtain the number of lines of the edited text.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

Return value

TypeDescription
numberNumber of lines of the edited text.

getCaretOffset11+

getCaretOffset(): CaretOffset

The getCaretOffset type is used to obtain the position information 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

TypeDescription
CaretOffsetPosition of the caret relative to the text box.

NOTE

  • If this API is called when the caret position is updated in the current frame, it will not take effect.
  • For the Search component, the returned position information is the offset of the first character relative to the search icon in the component.
  • If no text is entered in the Search component, the return value contains the position information relative to the component.
  • The location information in the return value is the location of the caret relative to the editable component.

addText15+

addText(text: string, textOperationOptions?: TextContentControllerOptions): number

Inserts text at a specified position in the editable content. If no position is specified, the text is appended to the end of the existing content. This API does not work when the text is being dragged.

Atomic service API: This API can be used in atomic services since API version 15.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

NameTypeMandatoryDescription
textstringYesText to insert.
textOperationOptionsTextContentControllerOptionsNoConfiguration option for inserting text. If this parameter is not provided, the text is appended to the end.

deleteText15+

deleteText(range?: TextRange): void

Deletes text within a specified range in the editable content. This API does not work when the text is being dragged.

Atomic service API: This API can be used in atomic services since API version 15.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

NameTypeMandatoryDescription
rangeTextRangeNoRange of the text to be deleted, including the start and end positions.
If the range is not specified, the entire text is deleted. If the start position is not specified, deletion starts from index 0. If the end position is not specified, deletion ends at the end of the text.

getSelection15+

getSelection(): TextRange

Obtains the current text selection range.

Atomic service API: This API can be used in atomic services since API version 15.

System capability: SystemCapability.ArkUI.ArkUI.Full

Return value

TypeDescription
TextRangeCurrent text selection range, or cursor position if no text is selected.

clearPreviewText18+

clearPreviewText(): void

Clears the current preview text.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Full

getText18+

getText(range?: TextRange): string

Obtains the text content within a specified range.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Full

Parameters

NameTypeMandatoryDescription
rangeTextRangeNoRange of the text content to obtain, defined by start and end positions.
If the range is not specified, the entire text is obtained by default. If the start position is not specified, it defaults to index 0. If the end position is not specified, it defaults to the end of the text.

Return value

TypeDescription
stringText content within the specified range.

TextDecorationOptions12+

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeMandatoryDescription
typeTextDecorationTypeYesStyle of the text decorative line.
Atomic service API: This API can be used in atomic services since API version 11.
colorResourceColorNoColor of the text decorative line.
Atomic service API: This API can be used in atomic services since API version 11.
styleTextDecorationStyleNoStyle of the text decorative line.
Atomic service API: This API can be used in atomic services since API version 12.

SelectionOptions12+

The SelectionOptions type is used to describe the configuration options for text selection.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeMandatoryDescription
menuPolicyMenuPolicyNoMenu display policy.

MenuPolicy12+

The MenuPolicy type is used to describe the menu display policy.

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameValueDescription
DEFAULT0Whether the menu is displayed depends on the underlying default logic.
HIDE1The menu is always hidden.
SHOW2The menu is always displayed.

CaretOffset11+

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeDescription
indexnumberIndex of the caret position.
xnumberX coordinate of the caret relative to the text box, in px.
ynumberY coordinate of the caret relative to the text box, in px.

InputCounterOptions11+

Atomic service API: This API can be used in atomic services since API version 12.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeDescription
thresholdPercentagenumberThreshold percentage for displaying the character counter. The character counter is displayed when the number of characters that have been entered is greater than the maximum number of characters multiplied by the threshold percentage value. When displayed, the character counter is in the following format: Number of characters that have been entered/Maximum number of characters allowed. It is visible when the number of characters entered is greater than the character limit multiplied by the threshold percentage value. Value range: [1, 100]
If the value is not an integer, it is rounded down to the nearest integer. If the value exceeds the valid value range, the character counter is not displayed. If the value is undefined, the character counter is displayed, but this parameter has no effect.
highlightBorderbooleanWhether to highlight the text box border and character counter subscript in red. If options is not set, the text box border and character counter subscript turn red when the number of characters entered reaches the limit. If the character counter is displayed and thresholdPercentage is set to a valid value, the text box border and character counter subscript turn red when the number of entered characters exceeds the limit. The value true (default) means to highlight the text box border and character counter subscript in red.

ChainWeightOptions14+

The ChainWeightOptions type is used to describe the layout weight of a component within a chain.

Atomic service API: This API can be used in atomic services since API version 14.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeDescription
horizontalnumberLayout weight of the component in the horizontal direction. It is effective when set to a value greater than 0.
Default value: 0
Invalid values are treated as 0.
verticalnumberLayout weight of the component in the vertical direction. It is effective when set to a value greater than 0.
Default value: 0
Invalid values are treated as 0.

Configuration

The Configuration type is used to describe the color mode and font scale.

Widget capability: This API can be used in ArkTS widgets since API version 9.

Atomic service API: This API can be used in atomic services since API version 11.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeRead OnlyOptionalDescription
colorModestringYesNoColor mode.
fontScalenumberYesNoFont scale.

LayoutPolicy15+

The LayoutPolicy type is used to set the layout strategy for linear layouts.

Widget capability: This API can be used in ArkTS widgets since API version 15.

Atomic service API: This API can be used in atomic services since API version 15.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeRead OnlyDescription
MATCH_PARENTLayoutPolicyYesAdjusts the size to match the parent component's layout.

NOTE

  • When the parent container of a linear layout component has its length set, the component will automatically adjust its size based on the parent container's size. If the parent container does not have a length set, the linear layout component will wait for all child components to complete their layout before adjusting its size to match the parent container's layout.

  • If multiple child components under the same parent are set to MATCH_PARENT, all these child components will be resized to the parent's size, potentially causing overflow.

  • Setting MATCH_PARENT will force the component to match the parent's size, overriding any other size constraints set on the component.

TextContentControllerOptions15+

The TextContentControllerOptions type is used to configure the insertion of text into a text box.

Atomic service API: This API can be used in atomic services since API version 15.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameTypeRead OnlyOptionalDescription
offsetnumberYesYesPosition where the text will be inserted.

DividerMode18+

The DividerMode type is used to configure the mode of the divider.

Atomic service API: This API can be used in atomic services since API version 18.

System capability: SystemCapability.ArkUI.ArkUI.Full

NameValueDescription
FLOATING_ABOVE_MENU0The divider floats above the menu without affecting the layout height. This is the default mode.
EMBEDDED_IN_MENU1The divider is embedded in the menu and affects the layout height.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙ArcButton

harmony 鸿蒙ArcSlider

harmony 鸿蒙Chip

harmony 鸿蒙ChipGroup

harmony 鸿蒙ComposeListItem

harmony 鸿蒙ComposeTitleBar

harmony 鸿蒙advanced.Counter

harmony 鸿蒙Dialog Box (Dialog)

harmony 鸿蒙DialogV2

harmony 鸿蒙DownloadFileButton

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/QdcP30