---
title: Input fields
product: Unity Spark
canonical: https://docs.unity.com/en-us/unity-spark/create/build/ui-editor/elements/input-fields
last_updated: 2026-12-01
generated_at: 2026-12-01T21:08:09.132Z
locale: en-us
---

# Input fields

> Let players enter text with the Input Field element in your Unity Spark UI.

An input field is a box that the player enters text into, such as the answer to a riddle, or a secret code that unlocks a door. A new input field shows the hint `Enter text...` until the player types.

## Input field settings

The **Input Field** [component](/unity-spark/create/build/components/about-components.md) contains the following main settings.

| **Setting**             | **Description**                                                                                                          |
| :---------------------- | :----------------------------------------------------------------------------------------------------------------------- |
| **Text**                | Sets the text in the field.                                                                                              |
| **Character Limit**     | Limits the number of characters the player can type. `0` means no limit.                                                 |
| **Content Type**        | Sets what the player can type, such as any text, whole numbers only, or masked text for passwords.                       |
| **Line Type**           | Determines whether the field holds one line or several.                                                                  |
| **Placeholder**         | Sets the hint text that shows when the field is empty. To change the hint, select the placeholder text inside the field. |
| **Read Only**           | Shows text that the player can't change.                                                                                 |
| **On Focus Select All** | Selects all the text when the player selects the field.                                                                  |

Buttons, sliders, toggles, input fields, and scrollbars share the following settings.

| **Setting**      | **Description**                                                                                                                                                                                                                                                     |
| :--------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **Interactable** | Sets whether the player can use the control. When **Interactable** is disabled, the control shows its **Disabled Color**.                                                                                                                                           |
| **Colors**       | Sets the tint for each state: **Normal Color**, **Highlighted Color** (when the pointer is over it), **Pressed Color**, **Selected Color**, and **Disabled Color**. **Color Multiplier** brightens every state, and **Fade Duration** sets how long a change takes. |

## Use the text the player enters

To use the text, ask the [AI assistant](/unity-spark/create/assistant/about-assistant.md), for example, `Open the vault door when the player types the code 1234.` You can also use a script. The field's `text` holds what the player typed. The following events pass the current text to your function.

| **Event**        | **When it happens**                                                         |
| :--------------- | :-------------------------------------------------------------------------- |
| `OnValueChanged` | Each time the text changes.                                                 |
| `OnSubmit`       | When the player presses **Enter**.                                          |
| `OnEndEdit`      | When the player finishes editing, for example, by selecting somewhere else. |

```lua
local function onCodeEntered(text)
  -- check the code the player typed
end

codeField:OnSubmit(onCodeEntered)
```

Pass a function that you define in the same script. Don't pass `self`, because the event calls the function you give it.

## Additional resources

* [Introduction to UI elements](/unity-spark/create/build/ui-editor/elements/about-ui-elements.md)
* [Sliders, toggles, and dropdowns](/unity-spark/create/build/ui-editor/elements/sliders-toggles-dropdowns.md)
* [Write and attach scripts](/unity-spark/create/build/scripts/write-scripts.md)
