Blazorise NumericEdit component

A native numeric <input> component built around the <input type="number">.

Use <NumericEdit> to have a field for any kind of numeric values. All basic types are supported, including nullable types (int, long, float, double, decimal, etc.).

Being built around native type="number" input element, the NumericEdit component in Blazorise has certain inherent limitations due to its reliance on native browser functionalities for numeric inputs. One such limitation is the handling of decimal values; for instance, inputting "0.0" may result in the component rounding the value to "0". This occurs because the browser considers "0.0" as a complete value, which triggers an onchange event. Internally, the component, not knowing the exact number of decimals intended, rounds the value and subsequently triggers a ValueChanged event. This, in turn, prompts a refresh, causing Blazor to redraw the NumericEdit component, which updates the value and the caret position.

Additionally, due to the component using the native type="number" partial values cannot be retrieved mid-entry. This means that constraints on the Value are only checked upon the blur event, allowing for the detection and handling of invalid values without interrupting the user's input process. To mitigate these issues, users could consider setting Immediate="false" to ensure the value is only submitted once focus is lost, or alternatively, use the NumericPicker component as a substitute.

Examples

Basic

<NumericEdit @bind-Value="@value" />
@code {
    decimal? value = 123;
}

Generic type

Since NumericEdit is a generic component you will have to specify the exact data type for the value. Most of the time it will be recognized automatically when you set the Value attribute, but if not you will just use the TValue attribute and define the type manually eg.
<NumericEdit TValue="decimal?" @bind-Value="@value" />
@code {
    decimal? value = 123;
}

API

Attributes

Name Description Type Default
TValue Generic type parameter used for the value attribute. generic
Value Gets or sets the value inside the input field. TValue default
ValueChanged Occurs after the value has changed. EventCallback<TValue>
Step Specifies the interval between valid values. decimal? null
Culture Helps define the localization of an element (used for parsing of the value). string null
Min The minimum value to accept for this input. TValue default
Max The maximum value to accept for this input. TValue default
Autofocus Set’s the focus to the component after the rendering is done. bool false
On this page