Input

A text field. Fires on every keystroke, or only when the user is done typing.

The smallest input#

Luau
main:Input({
    Text = "Target player",
    Callback = function(text)
        target = text
    end,
})
Live preview

My Script

v1.0

Filter

Building it up#

Hint at what goes in it:

Luau
main:Input({
    Text = "Target player",
    Placeholder = "Username…",
    Callback = setTarget,
})

Wait until they finish typing — fires on blur or Enter instead of every keystroke:

Luau
main:Input({
    Text = "Target player",
    Placeholder = "Username…",
    FireOnBlur = true,
    Callback = setTarget,
})

Every option#

OptionTypeDefaultWhat it does
TextreqstringThe label.
Callbackfunction(string)Called with the field's contents.
PlaceholderstringGhost text shown while the field is empty.
Defaultstring""Starting contents.
FireOnBlurbooleanfalseFire on blur or Enter instead of on every keystroke.
StylestringVisual variant, matching the button styles.
DescriptionstringA quieter second line.
IconstringAn icon shown before the label.
SavestringPersist under this key.

Methods#

MethodReturnsWhat it does
Get()stringThe current contents
Set(text)Replaces the contents and fires Callback

Which firing mode to use#

Per keystroke is right when the result is cheap and instant feedback is the point:

Luau
-- Filtering a list narrows as you type. Correct.
main:Input({ Text = "Filter", Callback = function(q) applyFilter(q) end })

FireOnBlur is right when a half-typed value is meaningless or costly:

Luau
-- Without FireOnBlur this fires on "S", then "St", then "Ste"…
main:Input({ Text = "Teleport to", FireOnBlur = true, Callback = teleportTo })