You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/pages/docs/getting-started.mdx
+87-81Lines changed: 87 additions & 81 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -39,72 +39,76 @@ local renderer = n.create_renderer({
39
39
40
40
Next, let's define the `body` variable that contains a two-row layout. In the first row, we have a text input field, followed by a small gap and a button labeled `Send`. The second row has a paragraph element that displays the text `nui.components`.
41
41
42
-
```lua showLineNumbers {8-29}
42
+
```lua showLineNumbers {8-31}
43
43
localn=require("nui-components")
44
44
45
45
localrenderer=n.create_renderer({
46
46
width=60,
47
47
height=8,
48
48
})
49
49
50
-
localbody=n.rows(
51
-
n.columns(
52
-
{ flex=0 },
53
-
n.text_input({
54
-
autofocus=true,
55
-
flex=1,
56
-
max_lines=1,
57
-
}),
58
-
n.gap(1),
59
-
n.button({
60
-
label="Send",
61
-
padding= {
62
-
top=1,
63
-
},
50
+
localbody=function()
51
+
returnn.rows(
52
+
n.columns(
53
+
{ flex=0 },
54
+
n.text_input({
55
+
autofocus=true,
56
+
flex=1,
57
+
max_lines=1,
58
+
}),
59
+
n.gap(1),
60
+
n.button({
61
+
label="Send",
62
+
padding= {
63
+
top=1,
64
+
},
65
+
})
66
+
),
67
+
n.paragraph({
68
+
lines="nui.components",
69
+
align="center",
70
+
is_focusable=false,
64
71
})
65
-
),
66
-
n.paragraph({
67
-
lines="nui.components",
68
-
align="center",
69
-
is_focusable=false,
70
-
})
71
-
)
72
+
)
73
+
end
72
74
```
73
75
74
76
The text input field has some custom settings. It will automatically gain focus when the renderer is mounted, it will take up all the available space in its row and it will only allow one line of text to be entered. The paragraph component will be centered horizontally, and it won't be focusable.
75
77
76
78
Finally, we can pass the `body` layout to the `renderer` function, which renders the defined layout.
77
79
78
-
```lua showLineNumbers {31}
80
+
```lua showLineNumbers {33}
79
81
localn=require("nui-components")
80
82
81
83
localrenderer=n.create_renderer({
82
84
width=60,
83
85
height=4,
84
86
})
85
87
86
-
localbody=n.rows(
87
-
n.columns(
88
-
{ flex=0 },
89
-
n.text_input({
90
-
autofocus=true,
91
-
flex=1,
92
-
max_lines=1,
93
-
}),
94
-
n.gap(1),
95
-
n.button({
96
-
label="Send",
97
-
padding= {
98
-
top=1,
99
-
},
88
+
localbody=function()
89
+
returnn.rows(
90
+
n.columns(
91
+
{ flex=0 },
92
+
n.text_input({
93
+
autofocus=true,
94
+
flex=1,
95
+
max_lines=1,
96
+
}),
97
+
n.gap(1),
98
+
n.button({
99
+
label="Send",
100
+
padding= {
101
+
top=1,
102
+
},
103
+
})
104
+
),
105
+
n.paragraph({
106
+
lines="nui.components",
107
+
align="center",
108
+
is_focusable=false,
100
109
})
101
-
),
102
-
n.paragraph({
103
-
lines="nui.components",
104
-
align="center",
105
-
is_focusable=false,
106
-
})
107
-
)
110
+
)
111
+
end
108
112
109
113
renderer:render(body)
110
114
```
@@ -116,7 +120,7 @@ Here's the result:
116
120
117
121
Now, let's make the UI implementation more reactive! Check out [this page](/docs/signal) to discover the power of `Signals`.
118
122
119
-
```lua showLineNumbers {6-9,15,26-34,36-40,43}
123
+
```lua showLineNumbers {6-9,16,27-35,37-41,44}
120
124
localrenderer=n.create_renderer({
121
125
width=60,
122
126
height=8,
@@ -127,43 +131,45 @@ local signal = n.create_signal({
0 commit comments