What are the built-in input components in Blazor forms (InputText, InputNumber, InputSelect, InputCheckbox, InputDate), and how do they integrate with EditForm?
Last updated
Blazor ships strongly-typed input components that wrap standard HTML inputs and integrate with the form's EditContext through two-way binding and automatic field tracking. You bind them with @bind-Value to a model property.
The built-in components:
InputTextandInputTextAreafor strings.InputNumberfor numeric types.InputSelectfor dropdowns (enums, lists).InputCheckboxfor booleans.InputDateandInputRadioGroupfor dates and radio sets.
How they integrate:
They receive the
EditContextas a cascading parameter (all derive fromInputBase<T>).On value change they notify the context via
NotifyFieldChanged, marking the field modified and triggering validation.They automatically apply CSS classes (
modified,valid,invalid) reflecting field state.
[lang:csharp]
<EditForm Model="person">
<InputText @bind-Value="person.Name" />
<InputNumber @bind-Value="person.Age" />
<InputDate @bind-Value="person.Birthday" />
<InputCheckbox @bind-Value="person.IsActive" />
</EditForm>
- https://learn.microsoft.com/en-us/aspnet/core/blazor/forms/input-components?view=aspnetcore-10.0
- https://chrissainty.com/creating-bespoke-input-components-for-blazor-from-scratch/
- https://blazor-university.com/forms/editing-form-data/
- https://learn.microsoft.com/en-us/aspnet/core/blazor/forms/?view=aspnetcore-10.0
- https://dev.to/rineshpk/editform-forms-and-validation-in-blazor-54h7
- https://wiemksaier.medium.com/a-practical-guide-to-blazor-editform-editcontext-and-validation-195d852f7d0e
- https://medium.com/@syeedmdtalha/blazor-forms-for-beginners-a-simple-guide-8a7010728fc4
- https://www.c-sharpcorner.com/article/validate-your-blazor-form-using-the-editform