Skip to main content

Input

Properties (All)

PropertyTypeDescription
typeInput Search TextAreaThe type of the input
defaultValuestringThe initial input content
addonAfterstringLabel displayed after the input field
addonBeforestringLabel displayed before the input field
allowClearbooleanAdds a button to clear input field
borderedbooleanWeather the input has a border
disabledbooleanWeather the input is disabled
maxLengthnumberMax allowed input length
prefixtableSee Prefix
suffixtableSee Suffix
showCountbooleanWhen true, input count will be displayed
statuserror, warningOutline color of the input, used for error and warning
sizelarge middle small numberSize of the input
onChangefunction(event)Fired when user changes input textfield
onPressEnterfunction(event)Fired when user presses enter while focused on input

Properties (Text Area)

PropertyTypeDescription
--ALL FROM All also work here!
autoSizenumbertable
PropertyTypeDescription
--ALL FROM All also work here!
enterButtontableSee EnterButton
loadingbooleanWeather the input is loading
onSearchfunction(value, event, source)Fired when the button is clicked

See more properties here.

Children

Input does not support children.

Example

local input = AM:createElement("Input", {
placeholder = "Input Here...",
width = "175px",
type = "search",
-- Fired when user changes input textfield
onChange = function(id, name, event)
local value = event.target.value
print("Value Changed To: " .. value)
--print("On Change Event: ", json.encode(event, {indent = true}))
end,
-- Fired when user presses enter on the keybaord.
onPressEnter = function(id, name, event)
local value = event.target.value
print("Presssed Enter. Value: " .. value)
end,
-- Fired when type="search" and the right-side button is pressd.
onSearch = function(id, name, value, event, source)
print("Search Button Pressed. Value: " .. value)
--print("onSearch: ", value, json.encode(event, {indent = true}), json.encode(source))
end,
})

Looks like:

Showcase

type

The type of input. Can be Input, Search or TextArea.

type

defaultValue

The default value in the input text area.

defaultValue = "Start Value"

defaultValue

addonAfter

Text displayed after the input textfield.

addonAfter = ".com"

addonAfter

In this example I have changed the type of the input field to default which is Input

addonBefore

Text displayed before the input textfield.

addonBefore = "http://"

Same as addonAfter, I've changed the type to Input.

allowClear

When true a clear button is displayed to clear the textfield.

allowClear

bordered

When false the outline and background is removed.

bordered

disabled

When true the input is disabled, not allowing the user to use it.

disabled

maxLength

Sets the max allowed length of the text user can write.

maxLength = 10

Will only allow the user to write 10 characters

maxLength

prefix

Text or Icon displayed before input field.

As usual icons can be found here.

Example
-- Icon display
prefix = {
type = "icon",
value = "FileSearchOutlined",
}

How icon prefix looks:

Prefix Icon

-- Text display
prefix = {
type = "text",
value = "PREFIX",
}

How text prefix looks:

Text Prefix

suffix

Suffix works just like prefix, but a suffix is after the input.

As usual icons can be found here.

Example

-- Icon display
suffix = {
type = "icon",
value = "FileSearchOutlined",
}

How icon suffix looks:

Prefix Suffix

-- Text display
suffix = {
type = "text",
value = "SUFFIX",
}

How text suffix looks:

Text Suffix

showCount

When true a number will be displayed depending on the type of input.

The count will increment with each character in the input

showCount

status

Can be either error or warning. Changes the outline color.

status error

status warning

size

Can be small, middle, large or any number.

When its a number, its treated as pixels.

size

onChange

Event is fired when user changes the input.

onPressEnter

Event is fired when the user presses enter while the input is focused.

onPressEnter = function(id, name, event)
local value = event.target.value
print("Presssed Enter. Value: " .. value)
--local ctrlKey = event.ctrlKey
--local shiftKey = event.shiftKey
--local altKey = event.altKey
--local key = event.key
end

You can also get more usefull information like weather the user is holding CTRL while pressing enter.

autoSize (TextArea only)

When true and type == "TextArea" the text area will size depending on the length of the users input.

Can also be a table like:

autoSize = {
minRows = 2,
maxRows = 6,
}

This will size the text are after the input.

enterButton (Search only)

Works like prefix and suffix, this just changes the "search" button of the search input.

enterButton = {
type = "text",
value = "TEXT",
}

1

enterButton = {
type = "icon",
value = "SearchOutlined",
}

2

loading (Search only)

When true the "search" button displays a loading icon, and prevets the user from clicking it.

Like so:

loading

onSearch (Search only)

Event is fired when the user presses the button when type == "Search".

onSearch = function(id, name, value, event, source)
print("Search Button Pressed. Value: " .. value)
--local ctrlKey = event.ctrlKey
--local shiftKey = event.shiftKey
--local altKey = event.altKey
--print("onSearch: ", value, json.encode(event, {indent = true}), json.encode(source))
end,

You can get usefull information like weather the user is holding CTRL, like shown above.