Skip to content

Number

Number components are Control Fields that allow the user to enter numeric values.

number.json
{
"form": [
{
"uid": "",
"kind": "control",
"widget": "number",
"path": "height",
"label": "Phone Number"
}
]
}

Use this props to customize your Number component.

proptypevalue
placeholderstringA placeholder text to display when the input number has no value
hintstringA description to display below the input number label
iconstringA css class to display an icon
iconPositionstringThe icon position, possible values are right or left
stepnumberStep value to jump on each keystroke using the arrow keys

Use the property placeholder to add a placeholder.

number.json
{
"form": [
{
"uid": "",
"kind": "control",
"widget": "number",
"path": "height",
"label": "Height in meters",
"props": {
"placeholder": "Please enter your height in meters (min 0 and max 2.5)"
}
}
]
}

Use the property hint to add a description.

number.json
{
"form": [
{
"uid": "",
"kind": "control",
"widget": "number",
"path": "number",
"label": "Phone Number",
"props": {
"hint": "This is a hint",
"placeholder": "Please enter your phone number"
}
}
]
}

Use the property icon to add an icon to the number. The value of icon represents a set of CSS classes separated by spaces. The icon is displayed on the left by default, you can set the property iconPosition to right if you want the icon to be right aligned.

number.json
{
"form": [
{
"uid": "",
"kind": "control",
"widget": "number",
"path": "number",
"label": "Phone Number",
"props": {
"icon": "material-icons material-icons-phone_callback",
"hint": "This is a hint",
"placeholder": "Please enter your phone number"
}
},
{
"uid": "",
"kind": "control",
"widget": "number",
"path": "number",
"label": "Phone Number",
"props": {
"icon": "material-icons material-icons-phone_callback",
"iconPosition": "right",
"hint": "This is a hint",
"placeholder": "Please enter your phone number"
}
}
]
}

Use the properties step to set a jump value on each keystroke using the arrow keys. This number can be decimal.

number.json
{
"form": [
{
"uid": "",
"kind": "control",
"widget": "number",
"path": "height",
"label": "Height in meters",
"props": {
"step": 0.01
}
}
]
}

Number inputs can be styled as explained in the Styling Guide.

Following you will find a list with the CSS Variables and a quick description of what you will style.

CSS VariableDescription
--gui-space-gap--innerLabel gap and margin bottom
--gui-paddingInput padding
--gui-color-borderInput border color
--gui-radiusInput radius
--gui-color-bgInput background color
--gui-color-fgInput text color
--gui-color-primaryInput border color and outline on focus
--gui-color-errorInput border color when invalid
--gui-space-gapIcon left padding
--gui-icon-space-gapIcon right padding
--gui-font-size--smallHint font size
--gui-color-fg--secondaryHint font color

This is the anatomy of the Number Component in case you want to use your CSS styles.

number.html
<gui-number>
<label for="fieldUid">
Label
<div class="gui-number__hint" id="fieldUid_hint">Hint</div>
</label>
<div class="gui-field">
<input
type="text"
inputmode="numeric"
min="0"
max="100"
step="0.01"
id="fieldUid"
class="gui-number__icon gui-number__icon--right"
disabled
readonly
placeholder="Custom placeholder"
aria-required="true"
aria-describedby="fieldUid_hint"
/>
<span class="gui-number__icon gui-number__icon--right"></span>
</div>
</gui-number>