Number input - Web Component
...
Attention!
The localization format of the input comes from the format settings of the client's operation system.
Browser support
Parameters
The Web component uses a <z-number-input>
tag.
The parametrization of the component can be done with the following custom HTML params:
Name | Type | Description |
---|---|---|
config | string | The main parameter has two components following the pattern:
|
label | string | Label of the input |
readonly (optional) | boolean | Transforms the input into an output |
value (optional) | string | Value of the model |
disabled (optional) | boolean | Blocks the interaction with the input component. |
required (optional) | boolean | Marks the input component as required. |
name (optional) | string | Identification for the field inside the form |
invalid (optional) | boolean | The forced state for set the input as invalid |
help-text (optional) | string | The forced message to be shown under the input |
range | number[] | First value is the minimum value of the input, second value is the maximum value of the input. |
step | number | Step value of the input. |
The events emitted from the component are:
Name | Payload | Description |
---|---|---|
onchange | number | Returns the new value of the "value" attribute |
Playground
Customization
HTML Examples
Imports
html
<link rel="stylesheet" href="/0.3.7/@zurich/web-components/styles.css" />
<script type="module" src="/0.3.7/@zurich/web-components/number-input.js"></script>
Code
html
<!-- Default -->
<z-number-input label="Number input"></z-number-input>
<z-number-input label="Number input" config="shaped"></z-number-input>
<!-- with value -->
<z-number-input label="Number input" value="-12.34"></z-number-input>
<z-number-input label="Number input" value="-12.34" config="shaped"></z-number-input>
<!-- disabled -->
<z-number-input label="Number input" disabled></z-number-input>
<z-number-input label="Number input" disabled config="shaped"></z-number-input>
<!-- readonly -->
<z-number-input label="Number input" readonly value="-12.34"></z-number-input>
<z-number-input label="Number input" readonly value="-12.34" config="shaped"></z-number-input>
<!-- with help text -->
<z-number-input label="Number input" help-text="Help text"></z-number-input>
<z-number-input label="Number input" help-text="Help text" config="shaped"></z-number-input>
<!-- invalid -->
<z-number-input label="Number input" help-text="Invalid input" invalid></z-number-input>
<z-number-input label="Number input" help-text="Invalid input" invalid config="shaped"></z-number-input>