Number Field
import {NumberField} from 'cx/widgets';The NumberField control is used for numeric inputs, including currencies and percentages.`
<div layout={LabelsLeftLayout}>
<NumberField label="Standard" value-bind="$page.number" autoFocus/>
<NumberField label="Disabled" value-bind="$page.number" disabled/>
<NumberField label="Readonly" value-bind="$page.number" readOnly/>
<NumberField label="Placeholder" value-bind="$page.number" placeholder="Type something here..."/>
<NumberField label="Validation" value-bind="$page.number" minValue={18} placeholder="Above 18..."/>
<NumberField label="Currency" value-bind="$page.number" placeholder="EUR" format="currency;EUR"/>
<NumberField label="Currency" value-bind="$page.number" placeholder="USD" format="currency;USD"/>
<NumberField scale={0.01} format="p" value-bind="$page.number" label="Percentage" />
</div>
<div layout={LabelsLeftLayout}>
<NumberField label="Formatted" value-bind="$page.number" format="n;2"/>
<NumberField label="Percentage" value-bind="$page.number" format="ps"/>
<NumberField label="Suffix" value-bind="$page.number" format="suffix; kg"/>
<NumberField label="Required" value-bind="$page.number" required/>
<NumberField label="Styled" value-bind="$page.number"
inputStyle={{border: '1px solid green'}}
icon="dollar"
showClear />
<NumberField label="View" value-bind="$page.number" mode="view"/>
<NumberField label="EmptyText" value-bind="$page.number" mode="view" emptyText="N/A"/>
<NumberField value-bind="$page.number" label="Actual Value" />
</div>| Property | Description | Type |
|---|---|---|
format | Template used to format the value. Examples: | string |
increment | Increment/decrement value when using arrow keys or mouse wheel.
Mouse wheel reaction must be explicitly enabled by setting the | number |
incrementPercentage | Percentage used to calculate the increment when it's not explicitly specified.
Default value is | number |
offset | An offset used to define mapping between displayed and stored values. E.g. 273.15 for displaying temperatures in Kelvins. | number |
scale | A scale used to define mapping between displayed and stored values. E.g. 0.01 for displaying percentages. | number |
snapToIncrement | Round values to the nearest tick. Default is | boolean |
value | Value of the input. | number |
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 |
constrain | When specified, values lower than | boolean |
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 |
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 |
maxExclusive | Set to | boolean |
maxValue | Largest allowed number value. | number |
minExclusive | Set to | boolean |
minValue | Smallest allowed number value. | number |
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 |
reactOn | Permitted values are | 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 |
validationMode | Defines how to present validation errors. Default mode is | string |
validationParams | An structured binding for additional validation parameters. Useful if validation depends on values
from other fields, e.g. confirm password. Calculated value is passed as the third argument to | structure |
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 |