---
title: "InputField"
language: "en"
type: "Symbol"
summary: "InputField[] represents a blank editable input field. InputField[x] represents an editable input field that currently contains the expression x. InputField[Dynamic[x]] takes the contents of the input field to be the dynamically updated current value of x, with the value of x being reset if new contents are entered. InputField[x, String] represents an input field whose contents are taken to be a string. InputField[x, Number] represents an input field whose contents are taken to be a number. InputField[x, type] represents an input field whose contents are taken to be of the specified type."
keywords: 
- input bar
- input box
- text field
- number field
- expression field
- user input field
- forms
canonical_url: "https://reference.wolfram.com/language/ref/InputField.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Control Objects"
    link: "https://reference.wolfram.com/language/guide/ControlObjects.en.md"
  - 
    title: "Creating Form Interfaces & Apps"
    link: "https://reference.wolfram.com/language/guide/CreatingFormsAndApps.en.md"
  - 
    title: "Creating Inspectors"
    link: "https://reference.wolfram.com/language/guide/CreatingInspectors.en.md"
  - 
    title: "Custom Interface Construction"
    link: "https://reference.wolfram.com/language/guide/CustomInterfaceConstruction.en.md"
  - 
    title: "Standalone Interfaces"
    link: "https://reference.wolfram.com/language/guide/StandAloneInterfaces.en.md"
  - 
    title: "Toolbars"
    link: "https://reference.wolfram.com/language/guide/Toolbars.en.md"
related_workflows: 
  - 
    title: "Build a Manipulate"
    link: "https://reference.wolfram.com/language/workflow/BuildAManipulate.en.md"
related_functions: 
  - 
    title: "Dynamic"
    link: "https://reference.wolfram.com/language/ref/Dynamic.en.md"
  - 
    title: "PopupMenu"
    link: "https://reference.wolfram.com/language/ref/PopupMenu.en.md"
  - 
    title: "Control"
    link: "https://reference.wolfram.com/language/ref/Control.en.md"
  - 
    title: "TableView"
    link: "https://reference.wolfram.com/language/ref/TableView.en.md"
  - 
    title: "Deploy"
    link: "https://reference.wolfram.com/language/ref/Deploy.en.md"
  - 
    title: "Input"
    link: "https://reference.wolfram.com/language/ref/Input.en.md"
  - 
    title: "Dialog"
    link: "https://reference.wolfram.com/language/ref/Dialog.en.md"
  - 
    title: "FileNameSetter"
    link: "https://reference.wolfram.com/language/ref/FileNameSetter.en.md"
  - 
    title: "Placeholder"
    link: "https://reference.wolfram.com/language/ref/Placeholder.en.md"
related_tutorials: 
  - 
    title: "Introduction to Dynamic"
    link: "https://reference.wolfram.com/language/tutorial/IntroductionToDynamic.en.md"
  - 
    title: "Introduction to Control Objects"
    link: "https://reference.wolfram.com/language/tutorial/IntroductionToControlObjects.en.md"
  - 
    title: "Generalized Input"
    link: "https://reference.wolfram.com/language/tutorial/GeneralizedInput.en.md"
---
# InputField

InputField[] represents a blank editable input field. 

InputField[x] represents an editable input field that currently contains the expression x. 

InputField[Dynamic[x]] takes the contents of the input field to be the dynamically updated current value of x, with the value of x being reset if new contents are entered. 

InputField[x, String] represents an input field whose contents are taken to be a string. 

InputField[x, Number] represents an input field whose contents are taken to be a number. 

InputField[x, type] represents an input field whose contents are taken to be of the specified type.

## Details and Options

* The following are possible types:

|                  |                          |
| :--------------- | :----------------------- |
| Boxes            | raw boxes                |
| Expression       | expression (default)     |
| Hold[Expression] | expression in held form  |
| Number           | number                   |
| String           | string                   |

* The setting for the input field is not updated until its contents are explicitly entered, typically by pressing $$\text{Key0}[\text{return}]$$ or by moving focus away from the input field.

* If the data given in the input field cannot be converted to the type specified, then the setting for the input field will not be updated.

* For ``String`` and ``Boxes`` types the conversion can always be done.

* For expressions, a blank input field is taken to have value ``Null``. For strings and boxes, it is taken to have value ``""``.

* tab moves between input fields.

* The following options can be given:

|                          |                              |                                                                                           |
| :----------------------- | :--------------------------- | :---------------------------------------------------------------------------------------- |
| Appearance               | Automatic                    | the overall appearance of the input field                                                 |
| Background               | Automatic                    | input field background color                                                              |
| BaselinePosition         | Automatic                    | how to align with a surrounding text baseline                                             |
| BaseStyle                | {}                           | base style specifications for the input field                                             |
| ContentPadding           | True                         | whether to shrink the margins tightly around the contents                                 |
| ContinuousAction         | False                        | whether to update continuously every time any change is made to the input                 |
| Enabled                  | Automatic                    | whether the input field is enabled or grayed out                                          |
| FieldCompletionFunction  | Automatic                    | function that takes the current value of the input field and returns possible completions |
| FieldHint                | Null                         | expression to display when the input field is empty                                       |
| FieldHintStyle           | {}                           | style to apply to the field hint                                                          |
| FieldMasked              | False                        | whether to mask characters in the input field                                             |
| FieldSize                | {{20., 20.}, {1., Infinity}} | the size of the input field                                                               |
| FrameMargins             | Automatic                    | minimum margins to leave inside the frame                                                 |
| ImageMargins             | 0                            | margins around the image of the displayed input field                                     |
| ImageSize                | Automatic                    | the overall image size of the displayed input field                                       |

* An ``InputField`` of type ``Expression`` replaces its contents with the fully evaluated form every time the contents are updated. ``ContinuousAction`` has no effect on such an ``InputField``, so that no disorienting replacements happen while typing inputs.

* Possible settings for ``Appearance`` include ``"Framed"`` and ``"Frameless"``.

* ``InputField[]`` is equivalent to ``InputField[Null]``.

* The settings for ``BaseStyle`` are appended to the default style typically given by the ``"InputField"`` style in the current stylesheet.

---

## Examples (26)

### Basic Examples (2)

Dynamically update the variable via the ``InputField`` :

```wl
In[1]:= {InputField[Dynamic[x]], Dynamic[x]}

Out[1]= {InputField[Dynamic[x]], Dynamic[x]}
```

---

Restrict the input to a specific type:

```wl
In[1]:= InputField[1, Number]

Out[1]= DynamicModule[«3»]

In[2]:= InputField["a", String]

Out[2]= DynamicModule[«3»]
```

### Scope (2)

Use tab to move between input fields:

```wl
In[1]:= {InputField[x, FieldSize -> 10], InputField[y, FieldSize -> 10]}

Out[1]= {DynamicModule[«3»], DynamicModule[«3»]}
```

---

The input field will not be updated if the input is not of the specified type:

```wl
In[1]:= InputField[1, Number]

Out[1]= DynamicModule[«3»]
```

### Options (16)

#### Appearance (1)

Display ``InputField`` without a frame:

```wl
In[1]:= Table[InputField[x, Appearance -> a], {a, {"Framed", "Frameless"}}]

Out[1]= {DynamicModule[«3»], DynamicModule[«3»]}
```

#### BaselinePosition (1)

Align ``InputField`` with text:

```wl
In[1]:= Row[Table[InputField[x, FieldSize -> 5, BaselinePosition -> p], {p, {Top, Bottom, Center}}], "xxxx"]

Out[1]=
Row[{InputField[x, FieldSize -> 5, BaselinePosition -> Top], 
  InputField[x, FieldSize -> 5, BaselinePosition -> Bottom], 
  InputField[x, FieldSize -> 5, BaselinePosition -> Center]}, "xxxx"]
```

#### BaseStyle (1)

Use a named style:

```wl
In[1]:= InputField[N[Pi], Number, BaseStyle -> {"ControlStyle"}]

Out[1]= DynamicModule[«3»]
```

#### ContentPadding (1)

Create an input field that is exactly as tall as its contents:

```wl
In[1]:= InputField["...", String, ContentPadding -> False, FrameMargins -> 0, FieldSize -> {Automatic, {0, Infinity}}]

Out[1]= DynamicModule[«3»]
```

#### ContinuousAction (2)

By default, variables are not continuously updated:

```wl
In[1]:= {InputField[Dynamic[x], String], Dynamic[x]}

Out[1]= {InputField[Dynamic[x], String], Dynamic[x]}
```

---

Setting ``ContinuousAction`` makes variable updates whenever a change is made to the input:

```wl
In[1]:= {InputField[Dynamic[y], String, ContinuousAction -> True], Dynamic[y]}

Out[1]= {InputField[Dynamic[y], String, ContinuousAction -> True], Dynamic[y]}
```

#### Enabled (2)

By default, ``InputField`` is enabled:

```wl
In[1]:= InputField[0.5]

Out[1]= DynamicModule[«3»]
```

---

By setting ``Enabled -> False``, the field is disabled but visible in its current state:

```wl
In[1]:= InputField[0.3, Enabled -> False]

Out[1]= DynamicModule[«3»]
```

#### FieldCompletionFunction (1)

Create an input field that offers completions of all matching System\` functions:

```wl
In[1]:= InputField[N, FieldCompletionFunction -> (Names["System`" <> ToString[#] <> "*"]&)]

Out[1]= DynamicModule[«3»]
```

#### FieldHint (1)

Display a prompt in an empty input field:

```wl
In[1]:= InputField["", String, FieldHint -> "Enter a string"]

Out[1]= DynamicModule[«3»]
```

#### FieldHintStyle (1)

Display the field hint in a different color:

```wl
In[1]:= InputField["", String, FieldHint -> "Enter text", FieldHintStyle -> {Red}]

Out[1]= DynamicModule[«3»]
```

#### FieldMasked (1)

Create a password-style input field:

```wl
In[1]:= DynamicModule[{password = "drowssap"}, Panel[Row[{"Password: ", InputField[Dynamic[password], String, FieldMasked -> True]}]]]

Out[1]= DynamicModule[«3»]
```

#### FieldSize (1)

Alter the field width:

```wl
In[1]:= Table[InputField[x, FieldSize -> s], {s, {3, 5, 10}}]

Out[1]= {DynamicModule[«3»], DynamicModule[«3»], DynamicModule[«3»]}
```

Adjust the height and width:

```wl
In[2]:= Grid[Table[InputField[x, FieldSize -> {w, h}], {h, {1, 3, 5}}, {w, {3, 5, 10}}]]

Out[2]=
|                    |                    |                    |
| ------------------ | ------------------ | ------------------ |
| DynamicModule[«3»] | DynamicModule[«3»] | DynamicModule[«3»] |
| DynamicModule[«3»] | DynamicModule[«3»] | DynamicModule[«3»] |
| DynamicModule[«3»] | DynamicModule[«3»] | DynamicModule[«3»] |
```

#### FrameMargins (1)

Set a large internal margin for an input field:

```wl
In[1]:= InputField[Expand[(a + b) ^ 2], FrameMargins -> 20]

Out[1]= DynamicModule[«3»]
```

#### ImageMargins (1)

Add margins outside the input field:

```wl
In[1]:= Table[Framed@InputField[x, ImageMargins -> m], {m, {0, 30, 50}}]

Out[1]= {DynamicModule[«3»], DynamicModule[«3»], DynamicModule[«3»]}
```

#### ImageSize (1)

Set the width of the field:

```wl
In[1]:= Table[InputField[x, ImageSize -> s], {s, {30, 50, 100}}]

Out[1]= {DynamicModule[«3»], DynamicModule[«3»], DynamicModule[«3»]}
```

Set the overall size of the field:

```wl
In[2]:= Grid[Table[InputField[x, ImageSize -> {w, h}], {h, {20, 40, 70}}, {w, {30, 50, 70}}]]

Out[2]=
|                    |                    |                    |
| ------------------ | ------------------ | ------------------ |
| DynamicModule[«3»] | DynamicModule[«3»] | DynamicModule[«3»] |
| DynamicModule[«3»] | DynamicModule[«3»] | DynamicModule[«3»] |
| DynamicModule[«3»] | DynamicModule[«3»] | DynamicModule[«3»] |
```

### Applications (1)

Plot any function:

```wl
In[1]:= Panel[DynamicModule[{f = Sin[x]}, Column[{InputField[Dynamic[f]], Dynamic[Plot[f, {x, -5, 5}]]}]]]

Out[1]= DynamicModule[«3»]
```

### Properties & Relations (1)

``Manipulator`` is constructed with ``InputField`` :

```wl
In[1]:= {Manipulator[Dynamic[x], Appearance -> "Open"], Dynamic[x]}

Out[1]= {DynamicModule[«3»], Dynamic[x]}

In[2]:= {Slider[Dynamic[y]], InputField[Dynamic[y]]}//Column

Out[2]=
Slider[Dynamic[y]]
InputField[Dynamic[y]]
```

### Possible Issues (4)

``InputField`` will remain unevaluated if the expression does not match the type:

```wl
In[1]:= InputField["a", Number]

Out[1]= InputField["a", Number]

In[2]:= InputField[2, Number]

Out[2]= DynamicModule[«3»]
```

---

Use a cleared ``Dynamic`` variable to create an empty input field that only accepts numbers:

```wl
In[1]:= DynamicModule[{x}, InputField[Dynamic[x], Number]]

Out[1]= DynamicModule[«3»]
```

---

``Null`` indicates no value in an input field of style ``Boxes`` :

```wl
In[1]:= InputField[Null, Boxes]

Out[1]= DynamicModule[«3»]
```

The box representation of the symbol ``Null`` is the string ``"Null"`` :

```wl
In[2]:= InputField["Null", Boxes]

Out[2]= DynamicModule[«3»]
```

---

``Null`` in an ``Expression`` style input field produces an empty result:

```wl
In[1]:= InputField[Null, Expression]

Out[1]= DynamicModule[«3»]
```

## See Also

* [`Dynamic`](https://reference.wolfram.com/language/ref/Dynamic.en.md)
* [`PopupMenu`](https://reference.wolfram.com/language/ref/PopupMenu.en.md)
* [`Control`](https://reference.wolfram.com/language/ref/Control.en.md)
* [`TableView`](https://reference.wolfram.com/language/ref/TableView.en.md)
* [`Deploy`](https://reference.wolfram.com/language/ref/Deploy.en.md)
* [`Input`](https://reference.wolfram.com/language/ref/Input.en.md)
* [`Dialog`](https://reference.wolfram.com/language/ref/Dialog.en.md)
* [`FileNameSetter`](https://reference.wolfram.com/language/ref/FileNameSetter.en.md)
* [`Placeholder`](https://reference.wolfram.com/language/ref/Placeholder.en.md)

## Tech Notes

* [Introduction to Dynamic](https://reference.wolfram.com/language/tutorial/IntroductionToDynamic.en.md)
* [Introduction to Control Objects](https://reference.wolfram.com/language/tutorial/IntroductionToControlObjects.en.md)
* [Generalized Input](https://reference.wolfram.com/language/tutorial/GeneralizedInput.en.md)

## Related Guides

* [Control Objects](https://reference.wolfram.com/language/guide/ControlObjects.en.md)
* [Creating Form Interfaces & Apps](https://reference.wolfram.com/language/guide/CreatingFormsAndApps.en.md)
* [Creating Inspectors](https://reference.wolfram.com/language/guide/CreatingInspectors.en.md)
* [Custom Interface Construction](https://reference.wolfram.com/language/guide/CustomInterfaceConstruction.en.md)
* [Standalone Interfaces](https://reference.wolfram.com/language/guide/StandAloneInterfaces.en.md)
* [`Toolbars`](https://reference.wolfram.com/language/guide/Toolbars.en.md)

## Related Workflows

* [Build a Manipulate](https://reference.wolfram.com/language/workflow/BuildAManipulate.en.md)

## History

* [Introduced in 2007 (6.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn60.en.md) \| [Updated in 2010 (8.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn80.en.md) ▪ [2016 (11.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn110.en.md)