Input
A text field for names, codes, search and chat, on one line or several. Its height grows on touch and console, and a focus ring shows while the player types in it. It can also limit what the player types: a number only, or a maximum length.


Lucy.Stack.new({
direction = "horizontal",
gap = "Space2",
align = "center",
children = {
Lucy.Input.new({
id = "playerName",
placeholder = "Your DJ name",
width = UDim.new(0, 280),
onSubmit = function(name)
app.toast(`See you on the floor, {name}`)
end,
}),
Lucy.Button.new({ text = "Save", icon = "lucide-extended:sparkles-filled" }),
},
Parent = parent,
})
Props
| Prop | Type | Default | State key | What it does |
|---|---|---|---|---|
value | string | "" | yes | The text in the field |
placeholder | string | "" | yes | Grey text shown while the field is empty |
size | string | "md" | yes | sm, md, lg or xl: the field’s height and text, as a Button of the same size, so they line up in a row or a form |
disabled | boolean | false | yes | Greys it out and stops typing |
visible | boolean | true | yes | Shows or hides it |
width | UDim | fills the parent | How wide the field is | |
maxLength | number | The most characters the player can type | ||
numeric | boolean | false | Only digits, a minus at the start and one point can be typed | |
multiline | boolean | false | Wraps text over several lines; Enter starts a new line | |
rows | number | 3 | How many lines tall a multiline field is | |
onChange | function | Called with (value, handle) as the text changes | ||
onSubmit | function | Called with (value, handle) on Enter or the gamepad confirm button (not in a multiline field) |
It also takes the props every component takes.
maxLength and numeric apply to what the player types. The value is always a string.
Methods
| Name | What it does |
|---|---|
input:focus() | Puts the cursor in the field |
Examples
Read the value by id:
local name = app.state:get("ui.playerName.value")
Keep a ref and the field in step:


local search = Lucy.ref("")
Lucy.Input.new({ placeholder = "Search emotes", value = search, Parent = emoteShop })
-- The emotes whose name has the search text, for a list's `data`
local shown = Lucy.computed(function()
local text = string.lower(search())
local found = {}
for _, emote in emotes do
if string.find(string.lower(emote.name), text, 1, true) then
table.insert(found, emote)
end
end
return found
end)
A message box that holds 200 characters:


Lucy.Input.new({
placeholder = "Message your crew",
multiline = true,
rows = 4,
maxLength = 200,
Parent = form,
})
A party code of six digits:


Lucy.Input.new({ placeholder = "Party code", numeric = true, maxLength = 6, Parent = form })
A fixed width:


Lucy.Input.new({ placeholder = "Party code", width = UDim.new(0, 160), Parent = row })
Preview
In Studio, from the command bar: Lucy.Preview.show("Input").