Text Field
import {TextField} from 'cx/widgets';Text field control is used for single line textual inputs. It's one of the mostly used controls. Many different states make it an advanced control.
<div layout={LabelsLeftLayout}>
<TextField label="Standard" value-bind="$page.text" autoFocus tabOnEnterKey />
<TextField label="Disabled" value-bind="$page.text" disabled />
<TextField label="Readonly" value-bind="$page.text" readOnly />
<TextField label="Placeholder" value-bind="$page.text" placeholder="Type something here..."/>
<TextField label="Tooltip" value-bind="$page.text" tooltip='This is a tooltip.'/>
</div>
<div layout={LabelsLeftLayout}>
<TextField label="Required" value-bind="$page.text" required trim />
<TextField label="Min/Max Length" value-bind="$page.text" minLength={3} maxLength={8}/>
<TextField label="Styled" value-bind="$page.text"
inputStyle={{border: '1px solid green'}}
icon={{
name: "search",
style: "pointer-events: all; cursor: pointer;",
onClick: (e) => {
e.stopPropagation();
MsgBox.alert("Icon clicked.");
},
tooltip: "This tooltip is displayed only over the icon."
}}
showClear />
<TextField label="View" value-bind="$page.text" mode="view" tooltip="Tooltips are shown in view mode too."/>
<TextField label="EmptyText" value-bind="$page.text" mode="view" emptyText="N/A"/>
</div>| Property | Description | Type |
|---|---|---|
inputType | Defaults to | string/array |
reactOn | Event used to report a new value. Defaults to | string |
value | Textual value of the input. | string |
alwaysShowClear | Set to | boolean |
autoFocus | Set to | boolean |
baseClass | Base CSS class to be applied to the field. Defaults to | string |
class | Additional CSS classes to be applied to the element. If an object is provided, all keys with a "truthy" value will be added to the CSS class list. | string/object |
disabled | Defaults to | boolean |
emptyText | Text to be rendered in view mode when the field is empty. | string |
emptyValue | Value to be written in the store when the field is empty. Default value is | any |
enabled | The opposite of | boolean |
error | Used for validation. If error evaluates to non-null, the field is marked in red. | string |
focused | If | any |
help | Additional content to be displayed next to the field. This is commonly used for presenting additional information or validation errors. | string/config |
helpPlacement | Set to | string |
helpSpacer | Indicates that | boolean |
hideClear | Set to | boolean |
icon | Name or configuration of the icon to be put on the left side of the input. | string/object |
id | Id to be used on rendered input. | string |
inputAttrs | Additional attributes that should be rendered on the input element.
E.g. | object |
inputClass | Additional CSS class applied to the input element. Used for setting visual elements, such as borders and backgrounds. | string/object |
inputStyle | Style object applied to the input element. Used for setting visual elements, such as borders and backgrounds. | string/object |
label | Field label. For advanced use cases, see Labels. | string/config |
labelClass | Additional CSS class to be passed to the label object. | string |
labelPlacement | Set to | string |
labelStyle | Additional CSS styles to be passed to the label object. | string/object |
maxLength | Maximal length of the input text. | string |
maxLengthValidationErrorText | Message to be shown to the user if input text is too long. | string |
minLength | Minimal length of the input text. | string |
minLengthValidationErrorText | Message to be shown to the user if input text is too short. | string |
mod | Appearance modifier. For example, | string/array |
mode | Either | string |
outerLayout | Defines the outer layout which wraps the widget. | widget |
placeholder | Default text displayed when the field is empty. | string |
putInto | Used with outer layouts. Specifies the name of the content placeholder which should render the widget. | string |
readOnly | Defaults to | boolean |
required | Defaults to | boolean |
showClear | Set to | string |
style | Style object applied to the wrapper div. Used for setting the dimensions of the element. | string/object |
tabIndex | Custom tab index to be set on the field. | string |
tabOnEnterKey | Set to | boolean |
tooltip | Tooltip configuration. For more info see Tooltips. | string/object |
trackFocus | If set to | boolean |
trim | Trim text to remove whitespace. Default is | boolean |
validationErrorText | Message to be shown to the user if validation fails. | string |
validationMode | Defines how to present validation errors. Default mode is | string |
validationParams | Validation params to be passed to the | any |
validationRegExp | Regular expression used to validate the user's input. | RegExp |
vdomKey | Key that will be used as the key when rendering the React component. | string |
viewMode | Set to | boolean |
visible | Visibility of the widget. Defaults to | boolean |
visited | Validation errors are not shown until the user visits the field. Setting this field to | boolean |