Skip to content
Razor catalogue

On this page

@addTagHelper *, Webority.Ui.Razor

Basic usage

Use a plain quantity field with no bounds, where the stepper moves by 1.

Quantity field
Show code
<app-number-input label="Quantity" name="qty" value="10"></app-number-input>

Bounds and step

Clamp the value to a range and set how far each stepper press moves it.

Rating with bounds
Show code
<app-number-input label="Rating" name="rating" value="7" min="0" max="10" step="1"></app-number-input>

Decimal values

Use precision to round the value to the decimal places you show, such as two for money.

Price field with 2 decimals
Show code
<app-number-input label="Price" name="price" value="19.99" precision="2" step="0.01"></app-number-input>

Unit suffix

Add a unit such as kg or % after the value, without making it part of the number.

Weight with unit
kg
Show code
<app-number-input label="Weight" name="weight" value="5" unit="kg"></app-number-input>

Sizes

Use md by default, sm in dense toolbars and lg where the field needs more presence.

All sizes
Show code
<app-number-input label="Small" name="s" value="10" size="Sm"></app-number-input>
<app-number-input label="Medium" name="m" value="10"></app-number-input>
<app-number-input label="Large" name="l" value="10" size="Lg"></app-number-input>

Validation

Mark required fields and give helper text; an error replaces the helper text when validation fails.

With required, helper text, and error
Minimum 1 unit
Required to proceed
Show code
<app-number-input label="Quantity" name="qty" value="0" required="true" helper-text="Minimum 1 unit"></app-number-input>
<app-number-input label="Quantity" name="qty-error" value="0" error="Required to proceed"></app-number-input>

Disabled and read only

Disable the field when it cannot be changed yet, or make it read only when its value must still post.

Locked field
Show code
<app-number-input label="Account ID" name="accId" value="12345" disabled="true"></app-number-input>
A read-only count
Show code
<app-number-input label="Seats" name="seats" value="12" read-only="true"></app-number-input>

Every option

Every value of every prop, one cell each.

size: all three

size="sm"
size="md" (default)
size="lg"

value: set, empty and defaultValue

value="10"
value="": empty field
value="10" (React: defaultValue={10}, uncontrolled start)

bounds: stepper disable states

value="0" min="0" (decrease disabled)
value="10" max="10" (increase disabled)
empty, min/max set: both steppers stay enabled
no min/max: steppers never disable

step: stepper amount

step="1" (default)
step="5"

precision: decimal rounding

precision="0" (default)
precision="1"
precision="2"
precision="4"

grouping: lakh and crore groups

grouping="Indian"
grouping="None" (default)

unit suffix

unit="kg"
kg
unit="°C"
°C
unit="/100" (longer suffix)
/100
(no unit)

label

label="Quantity"

required

required
(default): not required

optional

optional
optional with required: required wins, no (optional)
(default): no (optional) suffix

error and helper text

error="Required to proceed" (helper text hidden)
Minimum 1 unit
Required to proceed
helper-text="Minimum 1 unit"
Minimum 1 unit

help: info tip beside the label

help="Count the items in one order."
help-label="Quantity info" (the info tip name)

disabled and read only

disabled
read-only
(default): editable

loading

loading: busy state, input blocked

placeholder

placeholder="Enter a quantity"

name and id

name="qty-form" (posts with the form, no visible effect)
id="qty-field" (ties the label to the input, no visible effect)

className and input-class

input-class="opt-input-class" (React: className; extra classes on the input, no visible effect here)

fieldClassName and class

class="opt-field-class" (React: fieldClassName; extra classes on the field wrapper, no visible effect here)

onChange

onChange: React only, Razor posts the value with the form (no visible effect)

ref

ref: React only, Razor has no element ref (no visible effect)

stepper and optional labels

decrease-label="Less" (React: decreaseLabel; the decrease stepper name, no visible effect)
increase-label="More" (React: increaseLabel; the increase stepper name, no visible effect)
optional-label="(not needed)" (React: optionalLabel; text after the label when optional)

Guidance

What to do, and what to avoid.

Use it when

  • Any numeric input: quantities, prices, ratings, percentages.
  • When min/max bounds or precision rounding are important.
  • When keyboard stepping (Arrow Up/Down) would be helpful.
  • When a unit suffix (kg, °C, %) adds clarity.

Reach for something else when

  • Text or email. → AppInput
  • Multiple choice. → AppSelect or AppRadio
  • When free-text input is the only needed mode (buttons would be clutter).

Reference

Try every prop, read the full list, and check keyboard and screen reader behaviour.

none indian
sm md lg
React, generated from the controls
<AppNumberInput label="Quantity" name="pg-number" value={10} onChange={(next) => …} />
Razor, the same props
<app-number-input label="Quantity" name="pg-number" value="10" />

25 props. The 5 most used come first.

Used on most screens 5 props

PropTypeDefaultDescription
labeldefault - string - The field label
valuedefault - string - The current number; null or unset for an empty field.
requireddefault false bool false Marks the field as required, on the input and on the label.
helper-textdefault - string - Help text under the field, linked to the input for screen readers.
errordefault - string - An error message under the field. It sets the error state and aria-invalid on the input.

Less common 20 props

PropTypeDefaultDescription
namedefault - string - The input's name, for forms.
iddefault - string - The input's id. Unset, a generated id is used.
placeholderdefault - string - Text shown in the empty field.
optionaldefault false bool false Ends the label with (optional) when the field is not required. Required wins when both are set.
helpdefault - string - Info-tip content shown beside the label.
help-labeldefault More information string More information The accessible name of the info-tip button.
decrease-labeldefault Decrease string Decrease Replaces the built-in English text, for other languages.
increase-labeldefault Increase string Increase Replaces the built-in English text, for other languages.
optional-labeldefault (optional) string (optional) Replaces the built-in English text, for other languages.
mindefault - number - The lowest value, inclusive. The decrease stepper disables at it.
maxdefault - number - The highest value, inclusive. The increase stepper disables at it.
stepdefault 1 number 1 The amount one stepper click, or one ArrowUp or ArrowDown press, adds or removes.
precisiondefault 0 integer 0 The number of decimal places the value rounds to.
groupingdefault none none | indian none Digit grouping while the number is shown: indian writes 3,00,000 and posts the plain digits; none writes 300000.
unitdefault - string - A unit suffix shown inside the field after the input, such as kg or %.
disableddefault false bool false Disables the field and both steppers.
read-onlydefault false bool false Locks the field and both steppers; the value still posts.
loadingdefault false bool false Shows a busy state and blocks input while data loads.
sizedefault md sm | md | lg md Control size: sm, md or lg (32, 36 or 44px). md is the default.
input-classdefault - string - Extra classes on the input element itself

Screen reader

3 notes
  • The steppers are labelled Decrease and Increase and stay out of the tab order; keyboard users step with ArrowUp and ArrowDown on the input.
  • ArrowUp and ArrowDown step the value by step, within min and max.
  • aria-invalid is set from error, and aria-describedby points at the error or the helper text.