Forms

All form inputs in Moka.Red.Forms share a consistent API: Label, HelperText, ErrorText, Required, Disabled, Placeholder, @bind-Value, and inherited Size, Color, Variant from MokaVisualInputBase<TValue>.

Quick Reference

Component Input Type Notes
MokaTextField string Single-line text
MokaPasswordField string Toggle visibility
MokaNumericField<T> numeric Min, Max, Step
MokaTextArea string Multi-line, auto-resize
MokaCheckbox bool Indeterminate support
MokaSwitch bool Toggle on/off
MokaSlider numeric Range, ticks, marks
MokaRating numeric Star rating
MokaDatePicker DateOnly / DateTime Calendar popup
MokaTimePicker TimeOnly Clock popup
MokaColorPicker string Hue/saturation/lightness + hex
MokaFileUpload IBrowserFile Single/multi, drag-drop
MokaTagInput IList<string> Free-text tags with Enter
MokaRadioGroup TValue Radio button group
MokaAutoComplete<T> T Async/sync suggestions
MokaSearchInput string Debounced search field
MokaOtpInput string One-time password
MokaPhoneInput string Country code + number
MokaCurrencyInput decimal Locale-aware currency
MokaSignaturePad string Canvas draw → base64 PNG

TextField

@code { string _name = ""; }
<MokaTextField @bind-Value="_name" Label="Full name" Placeholder="Enter your name"
               HelperText="As it appears on your ID" Required />

PasswordField

@code { string _pwd = ""; }
<MokaPasswordField @bind-Value="_pwd" Label="Password" HelperText="Minimum 8 characters" />

NumericField

@code { int _qty = 1; }
<MokaNumericField TValue="int" @bind-Value="_qty" Label="Quantity" Min="1" Max="100" Step="1" />

TextArea

@code { string _bio = ""; }
<MokaTextArea @bind-Value="_bio" Label="Bio" Rows="4" AutoResize Placeholder="Tell us about yourself…" />

MokaTextArea Parameters (extras)

Name Type Default Description
Rows int 3 Initial visible rows
AutoResize bool false Grows with content
MaxRows int? Limits auto-resize height

Checkbox

@code { bool _agree; }
<MokaCheckbox @bind-Value="_agree" Label="I agree to the terms" />

Switch

@code { bool _notify = true; }
<MokaSwitch @bind-Value="_notify" Label="Email notifications" />

Slider

@code { double _vol = 50; }
<MokaSlider @bind-Value="_vol" Label="Volume" Min="0" Max="100" Step="5" ShowTicks />

Rating

@code { int _stars = 3; }
<MokaRating @bind-Value="_stars" Max="5" />

DatePicker

@code { DateTime? _date = DateTime.Today; }
<MokaDatePicker @bind-Value="_date" Label="Appointment date" />

TimePicker

@code { TimeSpan? _time = DateTime.Now.TimeOfDay; }
<MokaTimePicker @bind-Value="_time" Label="Meeting time" />

ColorPicker

@code { string _color = "#d32f2f"; }
<MokaColorPicker @bind-Value="_color" Label="Brand color" />

FileUpload

@code {
    IBrowserFile? _file;
    void OnFilesChange(IReadOnlyList<IBrowserFile> files) => _file = files.FirstOrDefault();
}
<MokaFileUpload Label="Upload document" OnFilesSelected="OnFilesChange" Accept=".pdf,.docx" />
@if (_file is not null)
{
    <MokaCaption>@_file.Name (@(_file.Size / 1024) KB)</MokaCaption>
}

TagInput

@code { IList<string> _tags = new List<string> { "blazor", "dotnet" }; }
<MokaTagInput @bind-Values="_tags" Label="Tags" Placeholder="Add tag and press Enter" />

RadioGroup

@code { string _plan = "pro"; }
<MokaRadioGroup @bind-Value="_plan" Label="Plan">
    <MokaRadioItem Value="@("free")">Free</MokaRadioItem>
    <MokaRadioItem Value="@("pro")">Pro</MokaRadioItem>
    <MokaRadioItem Value="@("enterprise")">Enterprise</MokaRadioItem>
</MokaRadioGroup>

AutoComplete

@code {
    string? _country;
    string[] _all = ["Germany", "France", "Italy", "Spain", "Poland"];
    Task<IEnumerable<string>> Search(string q)
        => Task.FromResult(_all.Where(c => c.Contains(q, StringComparison.OrdinalIgnoreCase)));
}
<MokaAutoComplete @bind-Value="_country" Label="Country" SearchFunc="Search" />

OtpInput

@code { string _otp = ""; }
<MokaOtpInput @bind-Value="_otp" Length="6" Label="Verification code" />

PhoneInput

@code { string _phone = ""; }
<MokaPhoneInput @bind-Value="_phone" Label="Phone number" CountryCode="+1" />

CurrencyInput

@code { decimal? _amount; }
<MokaCurrencyInput @bind-Value="_amount" Label="Invoice amount" CurrencyCode="USD" />

SignaturePad

@code { string? _sig; }
<MokaSignaturePad @bind-Value="_sig" Label="Signature" Height="120px" />
@if (_sig is not null)
{
    <img src="@_sig" style="border:1px solid #ccc;max-width:300px" />
}

Error State

All inputs support ErrorText to render an error message below the field.

<MokaTextField Label="Email" Value="not-an-email"
ErrorText="Please enter a valid email address." />

Disabled State

<div style="display:flex;flex-direction:column;gap:8px">
    <MokaTextField Label="Read-only field" Value="Cannot edit this" Disabled />
    <MokaSwitch Label="Disabled toggle" Value="true" Disabled />
</div>
Last updated: 2026-04-11
Was this page helpful?