Add a textfield component into your app.
Collect inputs from users. Inputs can be a number, text, emails, passwords and more. Just pass the corresponding type into
the options arguments to get your desired type of TextField.
If you want a materialize date and time pickers, see DatePicker, TimePicker or DateTimePicker components.
Properties
These are the setter and getter properties for the addTextField Component.
Example - Textfield variants
class Main extends App
{
onStart()
{
this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")
this.main.setChildMargins(0, 1, 0, 1, "rem")
this.tfd1 = ui.addTextField( this.main )
this.tfd1.label = "Enter text"
this.tfd1.setOnChange( this.onChange )
this.tfd2 = ui.addTextField(this.main, "", "Filled,Primary,Number")
this.tfd2.label = "Enter number"
this.tfd2.setOnChange( this.onChange )
this.tfd3 = ui.addTextField(this.main, "", "Outlined,Secondary,Email")
this.tfd3.label = "Enter email"
this.tfd3.setOnChange( this.onChange )
this.popup = ui.showPopup( "" )
this.popup.hide()
}
onChange( value )
{
this.popup.text = value
this.popup.show()
}
}
from hybrid import ui
def OnStart():
global popup
main = ui.addLayout("main", "Linear", "VCenter,FillXY")
main.setChildMargins(0, 1, 0, 1, "rem")
tfd1 = ui.addTextField(main)
tfd1.label = "Enter text"
tfd1.setOnChange(onChange)
tfd2 = ui.addTextField(main, "", "Filled,Primary,Number")
tfd2.label = "Enter number"
tfd2.setOnChange(onChange)
tfd3 = ui.addTextField(main, "", "Outlined,Secondary,Email")
tfd3.label = "Enter email"
tfd3.setOnChange(onChange)
popup = ui.showPopup("")
popup.hide()
def onChange(value):
popup.text = value
popup.show()
Example - Callbacks
class Main extends App
{
onStart()
{
this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")
this.main.setChildMargins(0.01, 0.01, 0.01, 0.05)
this.tfd = ui.addTextField(this.main, "", "Outlined,Secondary")
this.tfd.label = "Enter text"
this.tfd.setOnChange( this.onChange )
this.tfd.setOnEnter( this.onEnter )
this.btn = ui.addButton(this.main, "Get value", "Outlined,Secondary")
this.btn.setOnTouch( this.btn_onTouch )
this.popup = ui.showPopup( "" )
this.popup.hide()
}
onChange( value )
{
this.popup.text = "Change : " + value
this.popup.show()
}
onEnter( value )
{
this.popup.text = "Enter : " + value
this.popup.show()
}
btn_onTouch()
{
this.popup.text = "Value : " + this.tfd.text
this.popup.show()
}
}
from hybrid import ui
def OnStart():
global popup, tfd
main = ui.addLayout("main", "Linear", "VCenter,FillXY")
main.setChildMargins(0.01, 0.01, 0.01, 0.05)
tfd = ui.addTextField(main, "", "Outlined,Secondary")
tfd.label = "Enter text"
tfd.setOnChange(onChange)
tfd.setOnEnter(onEnter)
btn = ui.addButton(main, "Get value", "Outlined,Secondary")
btn.setOnTouch(btn_onTouch)
popup = ui.showPopup("")
popup.hide()
def onChange(value):
popup.text = "Change : " + value
popup.show()
def onEnter(value):
popup.text = "Enter : " + value
popup.show()
def btn_onTouch(event):
popup.text = "Value : " + tfd.text
popup.show()
Example - Multiline textfield
class Main extends App
{
onStart()
{
this.main = ui.addLayout("main", "Linear", "VCenter,FillXY")
this.txt = ui.addText(this.main, "This is a multiline type of TextField input", "Left", 0.8)
this.txt.setMargins(0, 0, 0, 0.05)
this.tfd = ui.addTextField(this.main, "", "Outlined,Secondary,Multiline", 0.8)
this.tfd.label = "Enter description"
this.tfd.setRows(3, 6)
}
}
from hybrid import ui
def OnStart():
main = ui.addLayout("main", "Linear", "VCenter,FillXY")
txt = ui.addText(main, "This is a multiline type of TextField input", "Left", 0.8)
txt.setMargins(0, 0, 0, 0.05)
tfd = ui.addTextField(main, "", "Outlined,Secondary,Multiline", 0.8)
tfd.label = "Enter description"
tfd.setRows(3, 6)
Example - Advance textfield
class Main extends App
{
onStart()
{
this.main = ui.addLayout("main", "Linear", "VCenter,ScrollY,FillXY")
this.main.setChildMargins(0.01, 0.01, 0.01, 0.01)
ui.addText(this.main, "Click the eye icon to show password.", "Left", 0.7)
this.tfd = ui.addTextField(this.main, "", "Outlined,Secondary,Password", 0.7)
this.tfd.label = "Enter password"
this.tfd.setStartAdornment("lock", "Icon")
this.tfd.setEndAdornment("visibility_off", "Icon,Touchable")
this.tfd.setEndAdornmentOnTouch( this.togglePasswordVisibility )
ui.addText(this.main, "Start text adornment", "Left,Overline", 0.7)
this.tfd1 = ui.addTextField(this.main, "", "Outlined,Secondary,Number", 0.7)
this.tfd1.label = "Enter mass"
this.tfd1.setStartAdornment("KG", "Text")
ui.addText(this.main, "Start icon adornment", "Left,Overline", 0.7)
this.tfd2 = ui.addTextField(this.main, "", "Outlined,Secondary", 0.7)
this.tfd2.label = "Enter username"
this.tfd2.setStartAdornment("person", "Icon")
ui.addText(this.main, "End text adornment", "Left,Overline", 0.7)
this.tfd3 = ui.addTextField(this.main, "", "Outlined,Secondary,Number", 0.7)
this.tfd3.label = "Enter amount"
this.tfd3.setEndAdornment("$", "Text")
ui.addText(this.main, "End icon adornment", "Left,Overline", 0.7)
this.tfd4 = ui.addTextField(this.main, "", "Outlined,Secondary,Password", 0.7)
this.tfd4.label = "Enter password"
this.tfd4.setEndAdornment("lock", "Icon")
}
togglePasswordVisibility()
{
if(this.tfd.endAdornment == "visibility_off")
{
this.tfd.setEndAdornment("visibility_on", "icon,touchable")
this.tfd.inputType = 'text'
}
else
{
this.tfd.setEndAdornment("visibility_off", "icon,touchable")
this.tfd.inputType = 'password'
}
}
}
from hybrid import ui
def OnStart():
main = ui.addLayout("main", "Linear", "VCenter,ScrollY,FillXY")
main.setChildMargins(0.01, 0.01, 0.01, 0.01)
ui.addText(main, "Click the eye icon to show password.", "Left", 0.7)
tfd = ui.addTextField(main, "", "Outlined,Secondary,Password", 0.7)
tfd.label = "Enter password"
tfd.setStartAdornment("lock", "Icon")
tfd.setEndAdornment("visibility_off", "Icon,Touchable")
tfd.setEndAdornmentOnTouch(togglePasswordVisibility)
ui.addText(main, "Start text adornment", "Left,Overline", 0.7)
tfd1 = ui.addTextField(main, "", "Outlined,Secondary,Number", 0.7)
tfd1.label = "Enter mass"
tfd1.setStartAdornment("KG", "Text")
ui.addText(main, "Start icon adornment", "Left,Overline", 0.7)
tfd2 = ui.addTextField(main, "", "Outlined,Secondary", 0.7)
tfd2.label = "Enter username"
tfd2.setStartAdornment("person", "Icon")
ui.addText(main, "End text adornment", "Left,Overline", 0.7)
tfd3 = ui.addTextField(main, "", "Outlined,Secondary,
Methods
The following methods are available on the TextField object:
Boolean: Sets or returns a boolean value whethe the input is focus when rendered into the DOM.
Boolean: Sets or returns the disabled state of the control.
Boolean: Sets or returns the error state of the TextField component.
Boolean: Returns whether the control is visible or not.
Boolean: Sets or returns a boolean value whether the text field in required or not.
Number: Fraction of the screen width.
Number: Fraction of the screen height.
Number: The time in milliseconds.
Number: The z-index. A negative value behaves like `sendBackward` method.
Number: The z-index. A positve value behaves like `bringForward` method.
Number: Border-left thickness in pixels.
Number: Top-Left border radius in pixels.
Number: Top-Right border radius in pixels.
Number: Bottom-Left border radius in pixels.
Number: Bottom-Right border radius in pixels.
Number: Fraction of the parent width.
Number: Fraction of the parent height.
Number: Fraction of the component width.
Number: Fraction of the component height. [0-1]
Number: Fraction of the component width. [0-1]
Number: Fraction of the parent width. [0-1]
Number: Fraction of the screen height. [0-1]
Number: The minimum number of rows.
Number: The maximum number of rows.
Number: The x-scale of the component.Values less than `0` is smaller than the normal. While values greater than `1` is greater than the normal.
Number: The y-scale of the component. Values less than `1` is smaller than the normal. While vaues greater than `1` is greater than the normal.
Number: Fraction of the parent height. [0-1]
Number: Returns the absolute height of the control in pixels.
Number: Returns the absolute distance of the control from the left in pixels.
Number: Returns the absolute distance of the control from the top in pixels.
Number: Returns the absolute width of the control in pixels.
Number: Sets or returns the border thickness in pixels.
Number: Sets or returns the corner radius in pixels.
Number: Sets or returns the height of the control as a fraction of the parent control.
Number: Returns the distance of the control from the left.
Number: Sets or returns the maximum rows for a multiline textfield.
Number: Sets or returns the minimum rows for a multiline textfield.
Number: Sets or returns the opacity of the control.
Number: Sets or returns the angle of rotation in degrees.
Number: Sets or returns the step increment if the input is of type number;
Number: Sets or returns the size of the text within the control.
Number: Returns the distance of the control from the top.
Number: Sets or returns the width of the control as a fraction of the parent control.
String: “The initial value of the TextField”
String: comma “,” separated: “Color: `Primary` or `Secondary`
`Sizes`: `Small` or `Medium`
`Type`: `Text` `Password` `Email` `Search` `Number` `Date` `Time` or `DateTime`
`Variant`: `Standard` `Filled` or `Outlined`
`Utils`: `Autofocus`”
String: “The type of animation. Here are the available values
`bounce` `flash` `pulse` `rubberBand` `shakeX` `shakeY` `headShake` `swing` `tada` `wobble` `jello` `heartBeat`
`Back Entrances `backInDown` `backInLeft` `backInRight` `backInUp`
`Back Exits `backOutDown` `backOutLeft` `backOutRight` `backOutUp`
`Bouncing Entrances `bounceIn` `bounceInDown` `bounceInLeft` `bounceInRight` `bounceInUp`
`Bouncing exits `bounceOut` `bounceOutDown` `bounceOutLeft` `bounceOutRight` `bounceOutUp`
`Fading entrances `fadeIn` `fadeInDown` `fadeInDownBig` `fadeInLeft` `fadeInLeftBig` `fadeInRight` `fadeInRightBig` `fadeInUp` `fadeInUpBig` `fadeInTopLeft` `fadeInTopRight` `fadeInBottomLeft` `fadeInBottomRight`
`Fading exits `fadeOut` `fadeOutDown` `fadeOutDownBig` `fadeOutLeft` `fadeOutLeftBig` `fadeOutRight` `fadeOutRightBig` `fadeOutUp` `fadeOutUpBig` `fadeOutTopLeft` `fadeOutTopRight` `fadeOutBottomRight` `fadeOutBottomLeft`
`Flippers `flip` `flipInX` `flipInY` `flipOutX` `flipOutY`
`Lightspeed `lightSpeedInRight` `lightSpeedInLeft` `lightSpeedOutRight` `lightSpeedOutLeft`
`Rotating Entrances `rotateIn` `rotateInDownLeft` `rotateInDownRight` `rotateInUpLeft` `rotateInUpRight`
`Rotating Exits `rotateOut` `rotateOutDownLeft` `rotateOutDownRight` `rotateOutUpLeft` `rotateOutUpRight`
`Specials `hinge` `jackInTheBox` `rollIn` `rollOut`
`Zooming Entrances `zoomIn` `zoomInDown` `zoomInLeft` `zoomInRight` `zoomInUp`
`Zooming Exits `zoomOut` `zoomOutDown` `zoomOutLeft` `zoomOutRight` `zoomOutUp`
`Sliding Entrances `slideInDown` `slideInLeft` `slideInRight` `slideInUp`
`Sliding Exits `slideOutDown` `slideOutLeft` `slideOutRight` `slideOutUp`.”
String: “The mode of the measurements. Values can be `px` or `%`”
String: “Border color in hexadecimal form `#rrggbb`”
String: “Border-styles. Values can be `dotted` `dashed` `solid` `double` `groove` `ridge` `inset` and `outset`. Default is `solid`”
String: “Unit. Values are `px` `rem` or `%`.”
String: “Text or material icon font.”
String: “A comma separated options for end adornment control. Options can be
`Icon` : If the adornment is an icon.
`Touchable` : If the adornment is touchable.”
String: “`px` or `%`”
String: “The size thickness mode. Can be `px`”
String: “Unit of measurement. Can be `px` or `%` or any css unit of measurement.”
String: “A comma separated options for start adornment control. Options can be
`Icon` : If the adornment is an icon.
`Touchable` : If the adornment is touchable.”
String: A hexadecimal color of the form #rrggbb
String: The path to your image file.
String: Sets or returns the border color. Color is in hexadecimal form #rrggbb
String: Sets or returns the border style. Values can be dotted, dashed, solid, double, groove, ridge, inset and outset. Default is solid.
String: Sets or returns the theme color of the textfield component.
String: Returns the end adornment text or icon.
String: Sets or returns the relative path to the font-family use.
String: Sets or returns the helper text or the hint below the input.
String: Sets or returns the hint text. It`s the same as the placeholder property.
String: Sets or returns the input type. See type params for available values.
String: Sets or returns the label text.
String: Sets return the label color in hexadecimal format #rrggbb
String: Sets or returns the options of the control.
String: Sets or returns the outline color in hexadecimal form #rrggbb when the textfield is focus.
String: Sets or returns the placeholder text.
String: Sets or returns the size variant of the textfield. Values can be Small or Medium
String: Returns the start adornment text or icon.
String: Sets or returns the text value of the TextField Component.
String: Sets or returns the color of the text.
String: Returns the type of the control.
String: Sets or returns the variant of the TextField. Values can be Standard Filled or Outlined
String: Sets or returns the visibility of the control.
Object: The layout where to add the TextField Component.
Object: The pointer event object.
Object: The click event object.
Object: Returns the parent layout control.
Object: Returns the position of the control. The returned object has left top right and bottom props.
List: Sets or returns the margin of the control. Works on controls with Linear parent only. You can also pass a number to set equal margins for all sides.
List: Sets or returns the padding of the control. You can also pass a number to set equal padding for all sides.
function()
tfd.animate
Animate the component
tfd.bringForward
Bring this component forward by a given z-index
tfd.destroy
Destroy the component
tfd.getEndAdornment
Returns the end adornment text
tfd.getPosition
Returns the position of the component. The return object is of the form `{ left, top, right, bottom
tfd.getStartAdornment
Returns the start adornment text
tfd.gone
Destroy the component
tfd.hide
Hide the component
tfd.sendBackward
Bring this component backward by a given z-index
tfd.setBorder
Sets the border line for the component container
tfd.setCornerRadius
Sets the corner radius of the component
tfd.setEndAdornment
Add an end adornment control into the TextField Component
tfd.setEndAdornmentOnTouch
Add a callback handler when the end adornment control is touch
tfd.setMargins
Sets the margin of the component
tfd.setOnChange
Sets a callback function on values changes event
tfd.setOnContextMenu
Adds a callback function on right click
tfd.setOnEnter
Sets a callback function on enter or submit event
tfd.setOnFocus
Adds a callback function when the textfield is focus or blur
tfd.setOnTouch
Adds a callback handler when the component is touch
tfd.setPadding
Sets the padding component container
tfd.setPosition
Sets the position of the component relative to its parent dimensions
tfd.setRows
Sets the minimum and maximum number of rows on a multiline type TextField
tfd.setScale
Sets the x and y scaling of the component
tfd.setSize
Sets the size of the component
tfd.setStartAdornment
Set a start adornment control into the TextField Component
tfd.setStartAdornmentOnTouch
Add a callback handler when the start adornment control is touch
tfd.show
Show the component