1# NodeContainer
2
3The **NodeContainer** component is a basic component that accepts an instance of [NodeController](../js-apis-arkui-nodeController.md) and does not allow child nodes to be appended. It must be used together with **NodeController**.
4
5> **NOTE**
6>
7> This component is supported since API version 11. Updates will be marked with a superscript to indicate their earliest API version.
8>
9> Only custom [FrameNodes](../js-apis-arkui-frameNode.md) or the root FrameNode obtained from a [BuilderNode](../js-apis-arkui-builderNode.md) can be attached to this component.
10> [Proxy nodes](../js-apis-arkui-frameNode.md#ismodifiable12) of built-in system components obtained through querying cannot be attached to this component.
11>
12> This component does not work with the [attribute modifer](./ts-universal-attributes-attribute-modifier.md).
13## Child Components
14
15Not supported
16
17## APIs
18
19### NodeContainer
20
21NodeContainer(controller: import('../api/@ohos.arkui.node').NodeController)
22
23**Atomic service API**: This API can be used in atomic services since API version 12.
24
25**System capability**: SystemCapability.ArkUI.ArkUI.Full
26
27**Parameters**
28
29| Name    | Type                                                | Mandatory| Description                                                        |
30| ---------- | ---------------------------------------------------- | ---- | ------------------------------------------------------------ |
31| controller | [NodeController](../js-apis-arkui-nodeController.md) | Yes  | **NodeController** instance used to control the upper and lower tree nodes in the **NodeContainer**. It represents the lifecycle of the **NodeContainer**.|
32## Attributes
33
34The [universal attributes](ts-universal-attributes-size.md) are supported.
35
36## Events
37
38The [universal events](ts-universal-events-click.md) are supported.
39
40## Example
41
42```ts
43import { NodeController, BuilderNode, FrameNode, UIContext } from '@kit.ArkUI';
44
45declare class Params {
46  text: string
47}
48
49@Builder
50function buttonBuilder(params: Params) {
51  Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceEvenly }) {
52    Text(params.text)
53      .fontSize(12)
54    Button(`This is a Button`, { type: ButtonType.Normal, stateEffect: true })
55      .fontSize(12)
56      .borderRadius(8)
57      .backgroundColor(0x317aff)
58  }
59  .height(100)
60  .width(200)
61}
62
63class MyNodeController extends NodeController {
64  private rootNode: BuilderNode<[Params]> | null = null;
65  private wrapBuilder: WrappedBuilder<[Params]> = wrapBuilder(buttonBuilder);
66
67  makeNode(uiContext: UIContext): FrameNode | null {
68    if (this.rootNode === null) {
69      this.rootNode = new BuilderNode(uiContext);
70      this.rootNode.build(this.wrapBuilder, { text: "This is a Text" })
71    }
72    return this.rootNode.getFrameNode();
73  }
74}
75
76
77@Entry
78@Component
79struct Index {
80  private baseNode: MyNodeController = new MyNodeController()
81
82  build() {
83    Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceEvenly }) {
84      Text("This is a NodeContainer contains a text and a button ")
85        .fontSize(9)
86        .fontColor(0xCCCCCC)
87      NodeContainer(this.baseNode)
88        .borderWidth(1)
89        .onClick(() => {
90          console.log("click event");
91        })
92    }
93    .padding({ left: 35, right: 35, top: 35 })
94    .height(200)
95    .width(300)
96  }
97}
98```
99![patternlock](figures/nodeContainer_sample.jpg)
100