# FrameNode
**FrameNode** represents an entity node in the component tree. It can be used by a [NodeController](./js-apis-arkui-nodeController.md#nodecontroller) to mount a [BuilderNode](./js-apis-arkui-builderNode.md#buildernode) (that holds the FrameNode) to a [NodeContainer](arkui-ts/ts-basic-components-nodecontainer.md#nodecontainer) or mount a [RenderNode](./js-apis-arkui-renderNode.md#rendernode) to another FrameNode.
> **NOTE**
>
> The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> **FrameNode** is not available in DevEco Studio Previewer.
>
> FrameNodes cannot be dragged.
## Modules to Import
```ts
import { FrameNode, LayoutConstraint, ExpandMode, typeNode, NodeAdapter } from "@kit.ArkUI";
```
## CrossLanguageOptions15+
Provides options for configuring or querying the cross-language access permissions for a FrameNode. For example, for nodes created using ArkTS, this API can control whether non-ArkTS languages are allowed to access or modify the properties of these nodes.
**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 |
| ------ | ------ | ---- | ---- | ---------------------- |
| attributeSetting | boolean | No | Yes | Whether the FrameNode supports cross-language settings. The default value is **false**.|
## ExpandMode15+
Enumerates the expansion mode of child nodes.
**Atomic service API**: This API can be used in atomic services since API version 15.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name| Value| Description|
| -------- | -------- | -------- |
| NOT_EXPAND | 0 | The child nodes of the current FrameNode are not expanded. If the FrameNode contains [LazyForEach](./arkui-ts/ts-rendering-control-lazyforeach.md) child nodes, the child nodes are not expanded when the nodes in the main tree are being obtained. The child node sequence numbers are calculated based on the nodes in the main tree.|
| EXPAND | 1 | The child nodes of the current FrameNode are expanded. If the FrameNode contains [LazyForEach](./arkui-ts/ts-rendering-control-lazyforeach.md) child nodes, all child nodes are expanded when being obtained. The child node sequence numbers are calculated based on all child nodes.|
| LAZY_EXPAND | 2 | The child nodes of the current FrameNode are expanded on demand. If the FrameNode contains [LazyForEach](./arkui-ts/ts-rendering-control-lazyforeach.md) child nodes, the child nodes are not expanded when the nodes in the main tree are being obtained, but are expanded when nodes not in the main tree are being obtained. The child node sequence numbers are calculated based on all child nodes.|
## FrameNode
### constructor
constructor(uiContext: UIContext)
Constructor used to create a FrameNode.
**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 |
| --------- | ----------------------------------------- | ---- | ---------------------------------- |
| uiContext | [UIContext](./js-apis-arkui-UIContext.md) | Yes | UI context required for creating a node.|
### getRenderNode
getRenderNode(): RenderNode | null
Obtains the RenderNode instance held in this FrameNode.
**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 |
| -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| [RenderNode](./js-apis-arkui-renderNode.md#rendernode) \| null | **RenderNode** instance. If the current FrameNode does not hold any RenderNode, **null** is returned. If the current FrameNode is a node created by a declarative component, **null** is returned.|
**Example**
```ts
import { NodeController, FrameNode } from '@kit.ArkUI';
class MyNodeController extends NodeController {
private rootNode: FrameNode | null = null;
makeNode(uiContext: UIContext): FrameNode | null {
this.rootNode = new FrameNode(uiContext);
const renderNode = this.rootNode.getRenderNode();
if (renderNode !== null) {
renderNode.size = { width: 100, height: 100 };
renderNode.backgroundColor = 0XFFFF0000;
}
return this.rootNode;
}
}
@Entry
@Component
struct Index {
private myNodeController: MyNodeController = new MyNodeController();
build() {
Row() {
NodeContainer(this.myNodeController)
}
}
}
```
### isModifiable12+
isModifiable(): boolean
Checks whether this FrameNode is modifiable.
**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 | Whether the current FrameNode is modifiable. When **false** is returned, the FrameNode does not support the **appendChild**, **insertChildAfter**, **removeChild**, and **clearChildren** operations.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### appendChild12+
appendChild(node: FrameNode): void
Appends a child node to the end of this FrameNode. If this FrameNode is not modifiable, an exception is thrown. When **appendChild** is called, [typeNode](#typenode12) validates the type or number of child nodes. If the validation fails, an exception is thrown. For specific limitations, see [typeNode](#typenode12).
**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 |
| ------ | ----------------------- | ---- | --------------------- |
| node | [FrameNode](#framenode) | Yes | Child node to append. **NOTE** The child node cannot be one created declaratively, which is not modifiable. Only declarative nodes obtained from a BuilderNode can be used as child nodes. If the child node does not meet the specifications, an exception is thrown. The FrameNode cannot have a parent node. Otherwise, an exception is thrown.|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------- |
| 100021 | The FrameNode is not modifiable. |
**Example**
See [Example of Node Operations](#example-of-node-operations).
### insertChildAfter12+
insertChildAfter(child: FrameNode, sibling: FrameNode | null): void
Inserts a child node after the specified child node of this FrameNode. If this FrameNode is not modifiable, an exception is thrown.
**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 |
| ------- | ----------------------------------------- | ---- | ---------------------------------------------------------------------------- |
| child | [FrameNode](#framenode) | Yes | Child node to add. **NOTE** The child node cannot be a declarative node, that is, a FrameNode that cannot be modified. Only declarative nodes obtained from a BuilderNode can be used as child nodes. If the child node does not meet the specifications, an exception is thrown. The child node cannot have a parent node. Otherwise, an exception is thrown. |
| sibling | [FrameNode](#framenode) \| null | Yes | Node after which the new child node will be inserted. If this parameter is left empty, the new node is inserted before the first subnode.|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------- |
| 100021 | The FrameNode is not modifiable. |
**Example**
See [Example of Node Operations](#example-of-node-operations).
### removeChild12+
removeChild(node: FrameNode): void
Deletes the specified child node from this FrameNode. If this FrameNode is not modifiable, an exception is thrown.
**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 |
| ------ | ----------------------- | ---- | ------------------ |
| node | [FrameNode](#framenode) | Yes | Child node to delete.|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------- |
| 100021 | The FrameNode is not modifiable. |
**Example**
See [Example of Node Operations](#example-of-node-operations).
### clearChildren12+
clearChildren(): void
Clears all child nodes of this FrameNode. If this FrameNode is not modifiable, an exception is thrown.
**Atomic service API**: This API can be used in atomic services since API version 12.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Error codes**
| ID| Error Message |
| -------- | -------------------------------- |
| 100021 | The FrameNode is not modifiable. |
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getChild12+
getChild(index: number): FrameNode | null
Obtains the child node in the specified position of this RenderNode.
**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 |
| ------ | ------ | ---- | -------------------------- |
| index | number | Yes | Index of the child node to obtain.|
**Return value**
| Type | Description |
| ------------------------------- | ------------------------------------------------------------- |
| [FrameNode](#framenode) \| null | Child node obtained. If the FrameNode does not contain the specified child node, null is returned.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getChild15+
getChild(index: number, expandMode?: ExpandMode): FrameNode | null
Obtains a child node at a specified index from this FrameNode, with optional support for specifying the expansion mode of the child node.
**Atomic service API**: This API can be used in atomic services since API version 15.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name| Type | Mandatory| Description |
| ------ | ------ | ---- | -------------------------- |
| index | number | Yes | Index of the child node to obtain.|
| expandMode | [ExpandMode](#expandmode15) | No| Expansion mode of the child node. Default value: **ExpandMode.Expand**|
**Return value**
| Type | Description |
| ------------------------------- | ------------------------------------------------------------- |
| [FrameNode](#framenode) \| null | Child node obtained. If the FrameNode does not contain the specified child node, null is returned.|
**Example**
See [Example of Node Operations in the LazyForEach Scenario](#example-of-node-operations-in-the-lazyforeach-scenario).
### getFirstChildIndexWithoutExpand15+
getFirstChildIndexWithoutExpand(): number
Obtains the sequence number of the first child node of this node that is in the main node tree. The child node sequence numbers are calculated based on all child nodes.
**Atomic service API**: This API can be used in atomic services since API version 15.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Return value**
| Type | Description |
| ------ | ---------------------------------------- |
| number | Sequence number of the first child node of this node that is in the main node tree.|
**Example**
See [Example of Node Operations in the LazyForEach Scenario](#example-of-node-operations-in-the-lazyforeach-scenario).
### getLastChildIndexWithoutExpand15+
getLastChildIndexWithoutExpand(): number
Obtains the sequence number of the last child node of this node that is in the main node tree. The child node sequence numbers are calculated based on all child nodes.
**Atomic service API**: This API can be used in atomic services since API version 15.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Return value**
| Type | Description |
| ------ | ------------------------------------------ |
| number | Sequence number of the last child node of this node that is in the main node tree.|
**Example**
See [Example of Node Operations in the LazyForEach Scenario](#example-of-node-operations-in-the-lazyforeach-scenario).
### getFirstChild12+
getFirstChild(): FrameNode | null
Obtains the first child node of this FrameNode.
**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 |
| ------------------------------- | --------------------------------------------------------- |
| [FrameNode](#framenode) \| null | First child node. If the FrameNode does not contain any child node, null is returned.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getNextSibling12+
getNextSibling(): FrameNode | null
Obtains the next sibling node of this FrameNode.
**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 |
| ------------------------------- | ------------------------------------------------------------------------------------ |
| [FrameNode](#framenode) \| null | Next sibling node of the current FrameNode. If the FrameNode does not have the next sibling node, null is returned.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getPreviousSibling12+
getPreviousSibling(): FrameNode | null
Obtains the previous sibling node of this FrameNode.
**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 |
| -------------------------------- | ------------------------------------------------------------------------------------ |
| [FrameNode](#framenode) \| null | Previous sibling node of the current FrameNode. If the FrameNode does not have the previous sibling node, null is returned.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getParent12+
getParent(): FrameNode | null;
Obtains the parent node of this FrameNode.
**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 |
| -------------------------------- | -------------------------------------------------------------------- |
| [FrameNode](#framenode) \| null | Parent node of the current FrameNode. If the FrameNode does not contain a parent node, null is returned.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getChildrenCount12+
getChildrenCount(): number;
Obtains the number of child nodes of this FrameNode.
**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 | Number of child nodes of the current FrameNode.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### moveTo16+
moveTo(targetParent: FrameNode, index?: number): void
Moves this FrameNode to a specified position within the target FrameNode. If this FrameNode is not modifiable, an exception is thrown. When **targetParent** is a [typeNode](#typenode12), the API validates the type or number of child nodes. If the validation fails, an exception is thrown. For specific limitations, see [typeNode](#typenode12).
> **NOTE**
>
> Currently, only the following types of [TypedFrameNode](#typedframenode12) are supported for the movement operations: [Stack](#stack12), [XComponent](#xcomponent12).
**Atomic service API**: This API can be used in atomic services since API version 16.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name | Type | Mandatory| Description |
| ------------ | ----------------------- | ---- | --------------------- |
| targetParent | [FrameNode](#framenode) | Yes | Target parent node. **NOTE** The target parent node must not be a declaratively created node, that is, a FrameNode that is not modifiable. If it does not meet the specifications, an exception is thrown.|
| index | number | No | Sequence number of the child node. The current FrameNode will be inserted before the child node at the specified sequence number in the target FrameNode. If the target FrameNode has *n* nodes, the value range for **index** is 0 to *n*-1. If the parameter is invalid or not specified, the current FrameNode will be added to the end of the target FrameNode. Default value: **-1**|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------- |
| 100021 | The FrameNode is not modifiable. |
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getPositionToWindow12+
getPositionToWindow(): Position
Obtains the position offset of this FrameNode relative to the window, in vp.
**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 |
| -------- | ------------------------------- |
| [Position](./js-apis-arkui-graphics.md#position) | Position offset of the node relative to the window, in vp.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getPositionToParent12+
getPositionToParent(): Position
Obtains the position offset of this FrameNode relative to the parent component, in vp.
**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 |
| -------------------------------------------------------------- | --------------------------------------------------------------------- |
| [Position](./js-apis-arkui-graphics.md#position) | Position offset of the node relative to the parent component, in vp.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getPositionToScreen12+
getPositionToScreen(): Position
Obtains the position offset of this FrameNode relative to the screen, in vp.
**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 |
| -------- | ------------------------------- |
| [Position](./js-apis-arkui-graphics.md#position) | Position offset of the node relative to the screen, in vp.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getPositionToParentWithTransform12+
getPositionToParentWithTransform(): Position
Obtains the position offset of this FrameNode relative to the parent component, taking into account drawing attributes such as **transform** and **translate**. The coordinates returned are the coordinates of the upper left corner during layout after transformation. The unit is vp.
**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 |
| -------------------------------------------------------------- | --------------------------------------------------------------------- |
| [Position](./js-apis-arkui-graphics.md#position) | Position offset of the node relative to the parent component, in vp. If other drawing attributes (such as **transform** and **translate**) are set, the return value may slightly deviate due to the precision of floating point numbers.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getPositionToWindowWithTransform12+
getPositionToWindowWithTransform(): Position
Obtains the position offset of this FrameNode relative to the window, taking into account drawing attributes such as **transform** and **translate**. The coordinates returned are the coordinates of the upper left corner during layout after transformation. The unit is vp.
**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 |
| -------------------------------------------------------------- | --------------------------------------------------------------------- |
| [Position](./js-apis-arkui-graphics.md#position) | Position offset of the node relative to the window, in vp. If other drawing attributes (such as **transform** and **translate**) are set, the return value may slightly deviate due to the precision of floating point numbers.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getPositionToScreenWithTransform12+
getPositionToScreenWithTransform(): Position
Obtains the position offset of this FrameNode relative to the screen, taking into account drawing attributes such as **transform** and **translate**. The coordinates returned are the coordinates of the upper left corner during layout after transformation. The unit is vp.
**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 |
| -------------------------------------------------------------- | --------------------------------------------------------------------- |
| [Position](./js-apis-arkui-graphics.md#position) | Position offset of the node relative to the screen, in vp. If other drawing attributes (such as **transform** and **translate**) are set, the return value may slightly deviate due to the precision of floating point numbers.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getMeasuredSize12+
getMeasuredSize(): Size
Obtains the measured size of this FrameNode, in px.
**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 |
| -------------------------------------------------------------- | --------------------------------------------------------------------- |
| [Size](./js-apis-arkui-graphics.md#size) | Measured size of the node, in px.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getLayoutPosition12+
getLayoutPosition(): Position
Obtains the position offset of this FrameNode relative to the parent component after layout, in px. The offset is the result of the parent component's layout on this node; therefore, the **offset** attribute that takes effect after layout and the **position** attribute that does not participate in layout do not affect this offset value.
**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 |
| -------------------------------------------------------------- | --------------------------------------------------------------------- |
| [Position](./js-apis-arkui-graphics.md#position) | Position offset of the current FrameNode relative to the parent component after layout, in px.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getUserConfigBorderWidth12+
getUserConfigBorderWidth(): Edges\
Obtains the border width set by the user.
**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 |
| -------------------------------------------------------------- | --------------------------------------------------------------------- |
| [Edges](./js-apis-arkui-graphics.md#edgest12)\<[LengthMetrics](./js-apis-arkui-graphics.md#lengthmetrics12)\> | Border width set by the user.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getUserConfigPadding12+
getUserConfigPadding(): Edges\
Obtains the padding set by the user.
**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 |
| -------------------------------------------------------------- | --------------------------------------------------------------------- |
| [Edges](./js-apis-arkui-graphics.md#edgest12)\<[LengthMetrics](./js-apis-arkui-graphics.md#lengthmetrics12)\> | Padding set by the user.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getUserConfigMargin12+
getUserConfigMargin(): Edges\
Obtains the margin set by the user.
**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 |
| -------------------------------------------------------------- | --------------------------------------------------------------------- |
| [Edges](./js-apis-arkui-graphics.md#edgest12)\<[LengthMetrics](./js-apis-arkui-graphics.md#lengthmetrics12)\> | Margin set by the user.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getUserConfigSize12+
getUserConfigSize(): SizeT\
Obtains the width and height set by the user.
**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 |
| ------------------------------------------------------------ | ---------------- |
| [SizeT](./js-apis-arkui-graphics.md#sizett12)\<[LengthMetrics](./js-apis-arkui-graphics.md#lengthmetrics12)\> | Width and height set by the user.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getId12+
getId(): string
Obtains the node ID set by the user (the [ID](./arkui-ts/ts-universal-attributes-component-id.md) set in the universal attributes).
**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 |
| -------------------------------------------------------------- | --------------------------------------------------------------------- |
| string | Node ID set by the user (the [ID](./arkui-ts/ts-universal-attributes-component-id.md) set in the universal attributes).|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getUniqueId12+
getUniqueId(): number
Obtains the system-assigned unique ID of the node.
**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 | System-assigned unique ID of the node.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getNodeType12+
getNodeType(): string
Obtains the type of the node. Built-in component types are named after the components themselves, for example, the type of a **Button** component is Button. For custom components, if they have rendering content, their type is __Common__.
**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 |
| -------------------------------------------------------------- | --------------------------------------------------------------------- |
| string | Type of the node.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getOpacity12+
getOpacity(): number
Obtains the opacity of the node. The minimum value is 0, and the maximum value is 1.
**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 | Opacity of the node.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### isVisible12+
isVisible(): boolean
Obtains whether the node is visible.
**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 | Whether the node is visible.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### isClipToFrame12+
isClipToFrame(): boolean
Checks whether the node is clipped to the component area. This API returns **true** after the [dispose](#dispose12) API is called to release the reference to the FrameNode.
**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 | Whether the node is clipped to the component area.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### isAttached12+
isAttached(): boolean
Obtains whether the node is mounted to the main node tree.
**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 | Whether the node is mounted to the main node tree.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getInspectorInfo12+
getInspectorInfo(): Object
Obtains the structure information of the node, which is consistent with what is found in DevEco Studio's built-in ArkUI Inspector tool.
**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 |
| -------------------------------------------------------------- | --------------------------------------------------------------------- |
| Object | Structure information of the node.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### getCustomProperty12+
getCustomProperty(name: string): Object | undefined
Obtains the component's custom property by its name.
**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 |
| ------ | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
| name | string | Yes | Name of the custom property.|
**Return value**
| Type | Description |
| -------------------------------------------------------------- | --------------------------------------------------------------------- |
| Object \| undefined | Value of the custom property.|
**Example**
See [Example of Node Operations](#example-of-node-operations).
### dispose12+
dispose(): void
Immediately releases the reference to the underlying FrameNode entity.
**Atomic service API**: This API can be used in atomic services since API version 12.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
> **NOTE**
>
> After the **dispose** API is called, the FrameNode object no longer corresponds to any entity FrameNode. In this case, attempts to call certain query APIs, such as [getMeasuredSize](#getmeasuredsize12) and [getLayoutPosition](#getlayoutposition12), will result in a JS crash in the application.
>
> To check whether the current FrameNode object corresponds to an entity FrameNode, you can use [getUniqueId](#getuniqueid12) API. A **UniqueId** value greater than 0 indicates that the object is associated with an entity FrameNode.
**Example**
```ts
import { NodeController, FrameNode, BuilderNode } from '@kit.ArkUI';
@Component
struct TestComponent {
build() {
Column() {
Text('This is a BuilderNode.')
.fontSize(16)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.backgroundColor(Color.Gray)
}
aboutToAppear() {
console.error('aboutToAppear');
}
aboutToDisappear() {
console.error('aboutToDisappear');
}
}
@Builder
function buildComponent() {
TestComponent()
}
class MyNodeController extends NodeController {
private rootNode: FrameNode | null = null;
private builderNode: BuilderNode<[]> | null = null;
makeNode(uiContext: UIContext): FrameNode | null {
this.rootNode = new FrameNode(uiContext);
this.builderNode = new BuilderNode(uiContext, { selfIdealSize: { width: 200, height: 100 } });
this.builderNode.build(new WrappedBuilder(buildComponent));
const rootRenderNode = this.rootNode.getRenderNode();
if (rootRenderNode !== null) {
rootRenderNode.size = { width: 200, height: 200 };
rootRenderNode.backgroundColor = 0xff00ff00;
rootRenderNode.appendChild(this.builderNode!.getFrameNode()!.getRenderNode());
}
return this.rootNode;
}
disposeFrameNode() {
if (this.rootNode !== null && this.builderNode !== null) {
this.rootNode.removeChild(this.builderNode.getFrameNode());
this.builderNode.dispose();
this.rootNode.dispose();
}
}
removeBuilderNode() {
const rootRenderNode = this.rootNode!.getRenderNode();
if (rootRenderNode !== null && this.builderNode !== null && this.builderNode.getFrameNode() !== null) {
rootRenderNode.removeChild(this.builderNode!.getFrameNode()!.getRenderNode());
}
}
}
@Entry
@Component
struct Index {
private myNodeController: MyNodeController = new MyNodeController();
build() {
Column({ space: 4 }) {
NodeContainer(this.myNodeController)
Button('FrameNode dispose')
.onClick(() => {
this.myNodeController.disposeFrameNode();
})
.width('100%')
}
}
}
```
### commonAttribute12+
get commonAttribute(): CommonAttribute
Obtains the **CommonAttribute** object held in this FrameNode for setting common attributes.
Note that only the attributes of a custom node can be modified.
**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 |
| -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| CommonAttribute | **CommonAttribute** object held in the current FrameNode for setting common attributes.|
> **NOTE**
>
> The visual representation of the FrameNode is similar to that of a [Stack](./arkui-ts/ts-container-stack.md) container that is aligned to the top start edge.
>
> For details about the supported attributes, see [CommonModifier](./arkui-ts/ts-universal-attributes-attribute-modifier.md#custom-modifier).
**Example**
See [Basic Event Example](#basic-event-example).
### commonEvent12+
get commonEvent(): UICommonEvent
Obtains the **UICommonEvent** object held in this FrameNode to set basic events. The set basic events will compete with declaratively defined events for event handling without overriding them. If two event callbacks are set at the same time, the callback for the declaratively defined event is prioritized.
In scenarios involving **LazyForEach**, where nodes may be destroyed and reconstructed, you need to reset or re-attach event listeners to the newly created nodes to ensure they respond to events correctly.
**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 |
| -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| [UICommonEvent](./arkui-ts/ts-uicommonevent.md#common-event-callback)| **UICommonEvent** object, which is used to set basic events.|
**Example**
See [Basic Event Example](#basic-event-example) and [Example of Using Basic Events in the LazyForEach Scenario](#example-of-using-basic-events-in-the-lazyforeach-scenario).
### gestureEvent14+
get gestureEvent(): UIGestureEvent
Obtains the **UIGestureEvent** object held by this FrameNode, which is used to set gesture events bound to the component. Gesture events set using the **gestureEvent** API will not override gestures bound using the [declarative gesture API](./arkui-ts/ts-gesture-settings.md). If both APIs are used to set gestures, the declarative API takes precedence.
**Atomic service API**: This API can be used in atomic services since API version 14.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Return value**
| Type | Description |
| -------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| [UIGestureEvent](./arkui-ts/ts-uigestureevent.md) | **UIGestureEvent** object, which is used to set the gestures bound to the component.|
**Example**
For details, see [Gesture Event Example](#gesture-event-example).
### onDraw12+
onDraw?(context: DrawContext): void
Called when this FrameNode performs content rendering.
**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 |
| ------- | ------------------------------------------------------ | ---- | ---------------- |
| context | [DrawContext](./js-apis-arkui-graphics.md#drawcontext) | Yes | Graphics drawing context. The self-drawing area cannot exceed the component's own size.|
**Example**
See [Example of Customizing a Node](#example-of-customizing-a-node).
### onMeasure12+
onMeasure(constraint: LayoutConstraint): void
Called when this FrameNode needs to determine its size. This API provides custom measurement and overrides the default measurement method.
**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 |
| ------- | ------------------------------------------------------ | ---- | ---------------- |
| constraint | [LayoutConstraint](#layoutconstraint12) | Yes | Layout constraints used by the component for measurement.|
**Example**
See [Example of Customizing a Node](#example-of-customizing-a-node).
### LayoutConstraint12+
Describes the layout constraints of the component.
**Atomic service API**: This API can be used in atomic services since API version 12.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name | Type | Mandatory | Description |
| -------------- | ------ | ----- | ------------------------------------------ |
| maxSize | [Size](./js-apis-arkui-graphics.md#size) | Yes | Maximum size. |
| minSize | [Size](./js-apis-arkui-graphics.md#size) | Yes | Minimum size. |
| percentReference | [Size](./js-apis-arkui-graphics.md#size) | Yes | Size reference for calculating the percentage of a child node.
### onLayout12+
onLayout(position: Position): void
Called when this FrameNode needs to determine its layout. This API provides custom layout and overrides the default layout method. It can be used to specify how the FrameNode and its child nodes are positioned and sized within the layout.
**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 |
| ------- | ------------------------------------------------------ | ---- | ---------------- |
| position | [Position](./js-apis-arkui-graphics.md#position) | Yes | Position information used in layout.|
**Example**
See [Example of Customizing a Node](#example-of-customizing-a-node).
### setMeasuredSize12+
setMeasuredSize(size: Size): void
Sets the measured size of this FrameNode. The default unit is PX. If the configured width and height are negative numbers, the value is automatically set to 0.
**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 |
| ------- | ------------------------------------------------------ | ---- | ---------------- |
| size | [Size](./js-apis-arkui-graphics.md#size) | Yes | Measured size of the FrameNode.|
**Example**
See [Example of Customizing a Node](#example-of-customizing-a-node).
### setLayoutPosition12+
setLayoutPosition(position: Position): void
Sets the position of this FrameNode after layout. The default unit is PX.
**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 |
| ------- | ------------------------------------------------------ | ---- | ---------------- |
| position | [Position](./js-apis-arkui-graphics.md#position) | Yes | Position of the FrameNode after layout.|
**Example**
See [Example of Customizing a Node](#example-of-customizing-a-node).
### measure12+
measure(constraint: LayoutConstraint): void
Measures this FrameNode and calculates its size based on the layout constraints of the parent container. If the measurement method is overridden, the overridden method is called. It is recommended that this API be called in [onMeasure](#onmeasure12).
**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 |
| ------- | ------------------------------------------------------ | ---- | ---------------- |
| constraint | [LayoutConstraint](#layoutconstraint12) | Yes | Parent container layout constraints used for measurement.|
**Example**
See [Example of Customizing a Node](#example-of-customizing-a-node).
### layout12+
layout(position: Position): void
Lays out this FrameNode, specifying the layout positions for the FrameNode and its child nodes. If the layout method is overridden, the overridden method is called. It is recommended that this API be called in [onLayout](#onlayout12).
**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 |
| ------- | ------------------------------------------------------ | ---- | ---------------- |
| position | [Position](./js-apis-arkui-graphics.md#position) | Yes | Position information used in layout.|
**Example**
See [Example of Customizing a Node](#example-of-customizing-a-node).
### setNeedsLayout12+
setNeedsLayout(): void
Marks this FrameNode as needing layout, so that it will be relaid out in the next frame.
**Atomic service API**: This API can be used in atomic services since API version 12.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Example**
See [Example of Customizing a Node](#example-of-customizing-a-node).
### invalidate12+
invalidate(): void
Invalidates this FrameNode to trigger a re-rendering of the self-drawing content.
**Atomic service API**: This API can be used in atomic services since API version 12.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
### addComponentContent12+
addComponentContent\(content: ComponentContent\): void
Adds component content. The current node must be modifiable, which means the return value of [isModifiable](#ismodifiable12) must be **true**. If the node is not modifiable, an exception is thrown.
**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 |
| ------- | ------------------------------------------------------ | ---- | ---------------- |
| content | [ComponentContent](./js-apis-arkui-ComponentContent.md#componentcontent)\ | Yes | Component content to display on the FrameNode.|
**Error codes**
| ID| Error Message |
| -------- | -------------------------------- |
| 100021 | The FrameNode is not modifiable. |
```ts
import { NodeController, FrameNode, ComponentContent, typeNode } from '@kit.ArkUI';
@Builder
function buildText() {
Column() {
Text('hello')
.width(50)
.height(50)
.backgroundColor(Color.Yellow)
}
}
class MyNodeController extends NodeController {
makeNode(uiContext: UIContext): FrameNode | null {
let node = new FrameNode(uiContext)
node.commonAttribute.width(300).height(300).backgroundColor(Color.Red)
let col = typeNode.createNode(uiContext, "Column")
col.initialize({ space: 10 })
node.appendChild(col)
let row4 = typeNode.createNode(uiContext, "Row")
row4.attribute.width(200)
.height(200)
.borderWidth(1)
.borderColor(Color.Black)
.backgroundColor(Color.Green)
let component = new ComponentContent