({{, (RefLink[InputField, paclet:ref/InputField])[]
represents a blank editable input field. }, {, (RefLink[InputField, paclet:ref/InputField])[x]
represents an editable input field that currently contains the expression x. }, {, (RefLink[InputField, paclet:ref/InputField])[(RefLink[Dynamic, paclet:ref/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. }, {, (RefLink[InputField, paclet:ref/InputField])[x,(RefLink[String, paclet:ref/String])]
represents an input field whose contents are taken to be a string. }, {, (RefLink[InputField, paclet:ref/InputField])[x,(RefLink[Number, paclet:ref/Number])]
represents an input field whose contents are taken to be a number. }, {, (RefLink[InputField, paclet:ref/InputField])[x,type]
represents an input field whose contents are taken to be of the specified type. }})

OpenersNotesSection(Spacer1)Details and Options

The following are possible types:

The setting for the input field is not updated until its contents are explicitly entered, typically by pressing (Key0[MacOSXreturnenter]) 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 (RefLink[String, paclet:ref/String]) and Boxes types the conversion can always be done.

For expressions, a blank input field is taken to have value (RefLink[Null, paclet:ref/Null]). For strings and boxes, it is taken to have value "".

(Key0[tab]) moves between input fields.

The following options can be given:

An (RefLink[InputField, paclet:ref/InputField]) of type (RefLink[Expression, paclet:ref/Expression]) replaces its contents with the fully evaluated form every time the contents are updated. (RefLink[ContinuousAction, paclet:ref/ContinuousAction]) has no effect on such an (RefLink[InputField, paclet:ref/InputField]), so that no disorienting replacements happen while typing inputs.

Possible settings for (RefLink[Appearance, paclet:ref/Appearance]) include "Framed" and "Frameless".

(RefLink[InputField, paclet:ref/InputField])[] is equivalent to (RefLink[InputField, paclet:ref/InputField])[(RefLink[Null, paclet:ref/Null])].

The settings for (RefLink[BaseStyle, paclet:ref/BaseStyle]) are appended to the default style typically given by the "InputField" style in the current stylesheet.

OpenersPrimaryExamplesSection(Spacer1)Examples  (26)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Dynamically update the variable via the (RefLink[InputField, paclet:ref/InputField]):

{InputField[Dynamic[x]],Dynamic[x]}

Restrict the input to a specific type:

InputField[1,Number]

InputField["a",String]

OpenersExampleSection1(Spacer1)Scope  (2)

Use (Key0[tab]) to move between input fields:

{InputField[x,FieldSize->10],InputField[y,FieldSize->10]}

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

InputField[1,Number]

OpenersExampleSection2(Spacer1)Options  (16)

OpenersExampleSubsection0(Spacer1)Appearance  (1)

Display (RefLink[InputField, paclet:ref/InputField]) without a frame:

Table[InputField[x,Appearance->a],{a,{"Framed","Frameless"}}]

OpenersExampleSubsection1(Spacer1)BaselinePosition  (1)

Align (RefLink[InputField, paclet:ref/InputField]) with text:

Row[Table[InputField[x,FieldSize->5,BaselinePosition->p],{p,{Top,Bottom,Center}}],"xxxx"]

OpenersExampleSubsection2(Spacer1)BaseStyle  (1)

Use a named style:

InputField[N[Pi],Number,BaseStyle->{"ControlStyle"}]

OpenersExampleSubsection3(Spacer1)ContentPadding  (1)

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

InputField["...",String,ContentPadding->False,FrameMargins->0,FieldSize->{Automatic,{0,Infinity}}]

OpenersExampleSubsection4(Spacer1)ContinuousAction  (2)

By default, variables are not continuously updated:

{InputField[Dynamic[x],String],Dynamic[x]}

Setting (RefLink[ContinuousAction, paclet:ref/ContinuousAction]) makes variable updates whenever a change is made to the input:

{InputField[Dynamic[y],String,ContinuousAction->True],Dynamic[y]}

OpenersExampleSubsection5(Spacer1)Enabled  (2)

By default, (RefLink[InputField, paclet:ref/InputField]) is enabled:

InputField[0.5]

By setting (RefLink[Enabled, paclet:ref/Enabled])->(RefLink[False, paclet:ref/False]), the field is disabled but visible in its current state:

InputField[0.3,Enabled->False]

OpenersExampleSubsection6(Spacer1)FieldCompletionFunction  (1)

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

InputField[N,FieldCompletionFunction->(Names["System`"<>ToString[#]<>"*"]&)]

OpenersExampleSubsection7(Spacer1)FieldHint  (1)

Display a prompt in an empty input field:

InputField["",String,FieldHint->"Enter a string"]

OpenersExampleSubsection8(Spacer1)FieldHintStyle  (1)

Display the field hint in a different color:

InputField["",String,FieldHint->"Enter text",FieldHintStyle->{Red}]

OpenersExampleSubsection9(Spacer1)FieldMasked  (1)

Create a password-style input field:

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

OpenersExampleSubsection10(Spacer1)FieldSize  (1)

Alter the field width:

Table[InputField[x,FieldSize->s],{s,{3,5,10}}]

Adjust the height and width:

Grid[Table[InputField[x,FieldSize->{w,h}],{h,{1,3,5}},{w,{3,5,10}}]]

OpenersExampleSubsection11(Spacer1)FrameMargins  (1)

Set a large internal margin for an input field:

InputField[Expand[(a+b)^2],FrameMargins->20]

OpenersExampleSubsection12(Spacer1)ImageMargins  (1)

Add margins outside the input field:

Table[Framed@InputField[x,ImageMargins->m],{m,{0,30,50}}]

OpenersExampleSubsection13(Spacer1)ImageSize  (1)

Set the width of the field:

Table[InputField[x,ImageSize->s],{s,{30,50,100}}]

Set the overall size of the field:

Grid[Table[InputField[x,ImageSize->{w,h}],{h,{20,40,70}},{w,{30,50,70}}]]

OpenersExampleSection3(Spacer1)Applications  (1)

Plot any function:

Panel[DynamicModule[{f=Sin[x]},Column[{InputField[Dynamic[f]],Dynamic[Plot[f,{x,-5,5}]]}]]]

OpenersExampleSection4(Spacer1)Properties & Relations  (1)

(RefLink[Manipulator, paclet:ref/Manipulator]) is constructed with (RefLink[InputField, paclet:ref/InputField]):

{Manipulator[Dynamic[x],Appearance->"Open"],Dynamic[x]}

{Slider[Dynamic[y]],InputField[Dynamic[y]]}//Column

OpenersExampleSection5(Spacer1)Possible Issues  (4)

(RefLink[InputField, paclet:ref/InputField]) will remain unevaluated if the expression does not match the type:

InputField["a",Number]

InputField[2,Number]

Use a cleared (RefLink[Dynamic, paclet:ref/Dynamic]) variable to create an empty input field that only accepts numbers:

DynamicModule[{x},InputField[Dynamic[x],Number]]

(RefLink[Null, paclet:ref/Null]) indicates no value in an input field of style Boxes:

InputField[Null,Boxes]

The box representation of the symbol (RefLink[Null, paclet:ref/Null]) is the string "Null":

InputField["Null",Boxes]

(RefLink[Null, paclet:ref/Null]) in an (RefLink[Expression, paclet:ref/Expression]) style input field produces an empty result:

InputField[Null,Expression]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Dynamic, paclet:ref/Dynamic])  ▪  (RefLink[PopupMenu, paclet:ref/PopupMenu])  ▪  (RefLink[Control, paclet:ref/Control])  ▪  (RefLink[Deploy, paclet:ref/Deploy])  ▪  (RefLink[Input, paclet:ref/Input])  ▪  (RefLink[Dialog, paclet:ref/Dialog])  ▪  (RefLink[FileNameSetter, paclet:ref/FileNameSetter])  ▪  (RefLink[Placeholder, paclet:ref/Placeholder])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Introduction to Dynamic, paclet:tutorial/IntroductionToDynamic])}, {▪(RefLinkPlain[Introduction to Control Objects, paclet:tutorial/IntroductionToControlObjects])}, {▪(RefLinkPlain[Generalized Input, paclet:tutorial/GeneralizedInput])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Control Objects, paclet:guide/ControlObjects])}, {▪(RefLinkPlain[Creating Form Interfaces & Apps, paclet:guide/CreatingFormsAndApps])}, {▪(RefLinkPlain[Creating Inspectors, paclet:guide/CreatingInspectors])}, {▪(RefLinkPlain[Custom Interface Construction, paclet:guide/CustomInterfaceConstruction])}, {▪(RefLinkPlain[Standalone Interfaces, paclet:guide/StandAloneInterfaces])}, {▪(RefLinkPlain[Toolbars, paclet:guide/Toolbars])}})}})